enum Example { case Step1 case Step2(data: String) }
和:
let a: Example = .Step1
let b: Example = .Step2(data: "hi")
我如何使这项工作?
print(a == b) // ERROR: Binary operator '==' cannot be applied to two 'Example' operands
请注意,我不能放弃自定义枚举(它不能包含原始值)
http://stackoverflow.com/questions/31548855/how-to-compare-enum-with-associated-values-by-ignoring-its-associated-value-in-s也可能是有用的。 – rmaddy