Skip to content

Instantly share code, notes, and snippets.

@bennokress
Last active January 12, 2018 19:59
Show Gist options
  • Save bennokress/4e826e9348b59fa5a4b719bf998c56ed to your computer and use it in GitHub Desktop.
Save bennokress/4e826e9348b59fa5a4b719bf998c56ed to your computer and use it in GitHub Desktop.
Extensions for Swift's Equatable Protocol
extension Equatable {
// Usage: 3.isAny(of: 0, 1, 2, 3) // true
func isAny(of candidates: Self...) -> Bool {
return candidates.contains(self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment