I\'ve had trouble finding/understanding documentation on how to compare enums in Swift by their order of definition. Specifically when I create an enumeration such as
Comparing enums as the OP wanted will be possible from Swift 5.3 onwards.
It works as below (from proposal):
enum Brightness: Comparable {
case low
case medium
case high
}
let expectedBrightness = Brightness.low
let actualBrightness = Brightness.high
if actualBrightness > expectedBrightness {
// Do something
}
More info and examples here.