[quote='797255021, swiftuiforever, /thread/797255, /profile/swiftuiforever'] Is this possible while inserting a String into Set [/quote] I’m not 100% sure. Historically it might’ve been possible to get into this situation if you had a custom subclass of NSString, but I tried that here in my office today and I’m not able to trigger it any more [1]. The most common source of errors like this is folks not maintaining the Hashable invariant. I explain that in detail below. Are you sure that frame 4 is working with Set rather than some custom type? Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com [1] For custom NSString subclasses, the compiler seems to eagerly bridge the contents over to a native String. One of the fundamental requirements of Hashable is that, if you values are equal, they must have the same hash [1]. This is what allows containers like Set and Dictionary to use hashing to speed up things up: They put each value in a bucket based
Topic:
Programming Languages
SubTopic:
Swift
Tags: