Created
February 26, 2020 18:02
-
-
Save endavid/d6de4761f2ab4902a92c4db75d700aa5 to your computer and use it in GitHub Desktop.
#swift equality functions for #medium
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
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