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.


Jeff Kelley

slauncha...@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@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)) !=
> b.hashValue(\(b.hashValue))")
> 
> It fails with error:
>    assertion failed: a.hashValue(4799450059707601744) != 
> b.hashValue(516202353)
> 
> Perhaps, there is an issue with the equality operator.
> 
> Alexey Komnin.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to