Skip to content

Instantly share code, notes, and snippets.

@superlopuh
Last active December 21, 2015 23:11
Show Gist options
  • Save superlopuh/9d461cfa2d6748cbaa11 to your computer and use it in GitHub Desktop.
Save superlopuh/9d461cfa2d6748cbaa11 to your computer and use it in GitHub Desktop.
Example of matching for any value in array.
let myString: String? = nil
func ~=<T: Equatable>(values: [T?], value: T?) -> Bool {
return values.contains({$0 == value})
}
if [nil, ""] ~= myString {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment