Last active
September 22, 2018 16:44
-
-
Save nanoxd/a56113ae5c731c90500394957145992b to your computer and use it in GitHub Desktop.
[Equatable+isAny] Check if an item that is equatable contains any of the items #swift
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
extension Equatable { | |
func isAny(of candidates: Self...) -> Bool { | |
return candidates.contains(self) | |
} | |
} | |
// Usage: | |
[1, 2, 3].isAny(of: 4, 1) // => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment