[swift-users] Set-uniqueness of instances with distinct hashValue
Dave Abrahams
dabrahams at apple.com
Sun Oct 23 13:04:09 CDT 2016
on Sun Oct 23 2016, milos <swift-users-AT-swift.org> wrote:
> Given an array of instances of a `Hashable` value type, all equal
> according to `Equatable` protocol, but with distinct `hashValue`s,
Equal hashables must have the same hashValue. If you violate this rule,
all bets are off. As the doc says:
A hash value, provided by a type's hashValue property, is an integer
that is the same for any two instances that compare equally. That is,
for two instances a and b of the same type, if a == b then a.hashValue
== b.hashValue.
https://developer.apple.com/reference/swift/hashable
--
-Dave
More information about the swift-users
mailing list