Avatar
swiftbot BOT 2/19/2020 5:29 AM
(edited)
nanasi
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)
Version:
swift-5.1.3-RELEASE
Output:
3666440306759404138 7344323318427966468 4893249820943752864 7344323318427966468 4893249820943752864
Error: