Avatar
@swiftbot enum EnumValue: Hashable { case a(Int) case b(Int) } enum EnumValue2: Hashable { case a(Int) case b(Int) func hash(into hasher: inout Hasher) { switch self { case .a(let v): hasher.combine(0) hasher.combine(v) case .b(let v): hasher.combine(1) hasher.combine(v) } } } print(5.hashValue) print(EnumValue.a(5).hashValue) print(EnumValue.b(5).hashValue) print(EnumValue2.a(5).hashValue) print(EnumValue2.b(5).hashValue) (edited)