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 Rien via swift-users
If you change the “==“ function to: func == (lhs: X, rhs: X) -> Bool { return (lhs.x == rhs.x) && (lhs.hashValue == rhs.hashValue) } then the example works as expected. Apple says this: “A hash value, provided by a type’s hashValue property, is an integer that is the same for any two

[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