[swift-users] Equality is broken, isn't it?
slaunchaman at gmail.com
Wed Jul 6 11:57:16 CDT 2016
I wouldn’t expect String and NSString to have identical implementations of hashValue(). Is there a problem you’re having that this example is meant to illustrate? I can see this being an issue if you’re building your own collection type for strings.
SlaunchaMan at gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org <http://jeffkelley.org/>
> On Jul 6, 2016, at 12:54 PM, Alexey Komnin via swift-users <swift-users at swift.org> wrote:
> Here is the code:
> let a: String = "abc"
> let b: NSString = "abc"
> assert(a == b)
> assert(a.hashValue == b.hashValue, "a.hashValue(\(a.hashValue)) !=
> It fails with error:
> assertion failed: a.hashValue(4799450059707601744) != b.hashValue(516202353)
> Perhaps, there is an issue with the equality operator.
> Alexey Komnin.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-users