Skip to content

Instantly share code, notes, and snippets.

@fxm90 fxm90/isset.swift
Last active Apr 23, 2017

Embed
What would you like to do?
Equivalent of php "isset()" in swift 3.0
func isset(_ args: Any?...) -> Bool {
return !args.contains { $0 == nil }
}
@fxm90

This comment has been minimized.

Copy link
Owner Author

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
You can’t perform that action at this time.