Last active
September 5, 2016 02:49
-
-
Save owenzhao/c8da4a1291eb8a03ce0a6d6ced640844 to your computer and use it in GitHub Desktop.
\`==\`与\`hashValue`
This file contains 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
class Fruit:Hashable { | |
let name:String | |
var hashValue: Int { | |
return name.hashValue | |
} | |
init(name:String) { | |
self.name = name | |
} | |
static func ==(lhs: Fruit, rhs: Fruit) -> Bool { | |
return lhs.name == rhs.name | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment