On Wed, Jul 6, 2016 at 9:54 AM, 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.
String and NSString use different comparison algorithms, and thus use incompatible hash codes. When you issue a mixed-type comparison, one is bridged to the other. Dmitri -- main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if (j){printf("%d\n",i);}}} /*Dmitri Gribenko <griboz...@gmail.com>*/ _______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users