Skip to content

Instantly share code, notes, and snippets.

@nanoxd
Last active September 22, 2018 16:44
Show Gist options
  • Save nanoxd/a56113ae5c731c90500394957145992b to your computer and use it in GitHub Desktop.
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
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