Last active
April 23, 2017 11:35
-
-
Save fxm90/dc15281c6253d6c35718baee0ea0b57d to your computer and use it in GitHub Desktop.
Equivalent of php "isset()" in swift 3.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func isset(_ args: Any?...) -> Bool { | |
return !args.contains { $0 == nil } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would evaluate to true
print(isset("a", 1, 2, true, false))
Would evaluate to false due to nil value
print(isset("a", 1, 2, true, false, nil))