[swift-evolution] Refining SE-0185: Should providing a custom == suppress the default hashValue?

Joe Groff jgroff at apple.com
Fri Dec 15 13:42:26 CST 2017



> On Dec 15, 2017, at 11:39 AM, Howard Lovatt via swift-evolution <swift-evolution at swift.org> wrote:
> 
> +1
> I think the simple solution of if you provide either == or hashValue you have to provide both is the best approach. Good catch of this bug. 

That would certainly be a simple rule. However, I think that it's more likely that someone might write their own hashValue in a way that's compatible with the default-derived equality semantics, so providing only explicit hashValue feels less problematic to me than providing explicit == and forgetting hashValue.

-Joe



More information about the swift-evolution mailing list