Hashable - overriding hashValue

I believe that @sjavora has already answered your question, but if you'd like to know a bit more about how Swift automatically synthesizes Hashable conformance you may find this thread informative:

There's even a section on this topic in Adopting Common Protocols:

Use All Significant Properties for Equatable and Hashable

When implementing the == method and the hash(into:) method, use all the properties that affect whether two instances of your custom type are considered equal. In the implementations above, the Player type uses name and position in both methods.

If your type contains properties that don't affect whether two instances are considered equal, exclude those properties from comparison in the == method and from hashing in hash(into:) . For example, a type might cache an expensive computed value so that it only needs to calculate it once. If you compare two instances of that type, whether or not the computed value has been cached shouldn't affect their equality, so the cached value should be excluded from comparison and hashing.


Important

Always use the same properties in both your == and hash(into:) methods. Using different groups of properties in the two methods can lead to unexpected behavior or performance when using your custom type in sets and dictionaries.