Re: [swift-users] Set-uniqueness of instances with distinct hashValue

2016-10-23 Thread milos via swift-users
Yes, Rien, just realised that. Now I must find some place to hide in shame… Thanks for your reply, though! milos ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

Re: [swift-users] Set-uniqueness of instances with distinct hashValue

2016-10-23 Thread milos via swift-users
Ah, one should never post to a mailing list before a morning coffee! The reason for the essentially undefined behaviour is that `Hashable` conformance must guarantee that two instances have the same `hashValue` if they are `==`, **but not vice versa**! In other words, the equality in the code s

[swift-users] Set-uniqueness of instances with distinct hashValue

2016-10-23 Thread milos via swift-users
Given an array of instances of a `Hashable` value type, all equal according to `Equatable` protocol, but with distinct `hashValue`s, I would expect that initialising a set with that array would preserve all the instances. Instead, running the code below in an iOS playground on Xcode 8.0 (8A218a