Comparing enums without their associated values

How about a synthesised property - caseValue (similar to rawValue). For example:

enum Foo {
  case one
  case two(Int)
}

let test1 = Foo.one
let test2 = Foo.two(3)

let value1 = test1.caseValue // Foo.one
let value2 = test2.caseValue // Foo.two

Could call it case or caseValue - I'm fine either way.

4 Likes