Consider:
enum Test {
case foo
case bar
case baz
case etc
}
var test: Test = ...
I would like to test whether the enum is bar
in particular. I could just use a switch statement:
switch test {
case .bar:
doSomething()
default:
break
}
It would be far neater if I could instead use if
:
if test == .bar {
doSomething()
}
But unless I'm missing something, there is no way to do that:
Binary operator '==' cannot be applied to two 'Test' operands
Is this possible, and if not, was this a deliberate language design decision?