According to Hashabledocs: (see the bottom of this page)
Types that conform to the Hashable protocol must contain the gettable Int property, called hashValue, and must also provide the implementation of the equal operator (==).
Equatable docs , ==, .
func == (lhs: MyStruct, rhs: MyStruct) -> Bool {
return lhs.name == rhs.name
}
, :
class Item : Printable, Hashable {
var description:String {
return "..."
}
var hashValue:Int {
return 1
}
}
func == (lhs: Item, rhs: Item) -> Bool {
return lhs.hashValue == rhs.hashValue
}
Item() == Item()
, hashValue - , , , , .