Skip to content

Instantly share code, notes, and snippets.

@endavid
Created February 26, 2020 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save endavid/d6de4761f2ab4902a92c4db75d700aa5 to your computer and use it in GitHub Desktop.
Save endavid/d6de4761f2ab4902a92c4db75d700aa5 to your computer and use it in GitHub Desktop.
#swift equality functions for #medium
func ==(lhs: Bread, rhs: Bread) -> Bool {
return lhs.rating == rhs.rating
}
b1 == b2 // true
func ==(lhs: Cheese, rhs: Cheese) -> Bool {
return lhs.rating == rhs.rating
}
c1 == c2 // true
c1 == c4 // false
cheeses.contains(c1) // still an error! not Equatable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment