Hashable allows a type to be converted into a hash value
for fast comparison and lookup.
It enables a value to be used in:
SetDictionary keysGoal: O(1) lookup instead of O(n)
Instead of scanning all elements:
Array → linear search (slow)
Set/Dictionary → hash-based lookup (fast)
A type conforming to Hashable must:
1. Provide a hash value
2. Support equality comparison (Equatable)
Swift automatically synthesizes this for simple structs.
struct Framework: Hashable {
let name: String
}
Swift auto-generates:
hash(into:)