Avatar
swiftbot BOT 2/19/2020 5:27 AM
nanasi
struct Value: Hashable { let id = 5 } struct Value2: Hashable { let id = 5 func hash(into hasher: inout Hasher) { hasher.combine(id) } } 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(v) case .b(let v): hasher.combine(v) } } } print(5.hashValue) print(Value().hashValue) print(Value2().hashValue) print(EnumValue.a(5).hashValue) print(EnumValue.b(5).hashValue) print(EnumValue2.a(5).hashValue) print(EnumValue2.b(5).hashValue)
Version:
swift-5.1.3-RELEASE
Output:
-5563881854129666050 -5563881854129666050 -5563881854129666050 1174769019477244301 8537611810857838151 -5563881854129666050 -5563881854129666050
Error: