Skip to content

Instantly share code, notes, and snippets.

@fxm90
Last active April 23, 2017 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fxm90/dc15281c6253d6c35718baee0ea0b57d to your computer and use it in GitHub Desktop.
Save fxm90/dc15281c6253d6c35718baee0ea0b57d to your computer and use it in GitHub Desktop.
Equivalent of php "isset()" in swift 3.0
func isset(_ args: Any?...) -> Bool {
return !args.contains { $0 == nil }
}
@fxm90
Copy link
Author

fxm90 commented Apr 23, 2017

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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment