Skip to content

Instantly share code, notes, and snippets.

@owenzhao
Last active September 5, 2016 02:49
Show Gist options
  • Save owenzhao/c8da4a1291eb8a03ce0a6d6ced640844 to your computer and use it in GitHub Desktop.
Save owenzhao/c8da4a1291eb8a03ce0a6d6ced640844 to your computer and use it in GitHub Desktop.
\`==\`与\`hashValue`
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