I'd like this code to work.
I have an enum where the case Direction.Right takes a distance parameter.
enum Direction {
case Up
case Down
case Left
case Right(distance: Int)
}
Now another enum that can take a Direction parameter.
enum Blah {
case Move(direction: Direction)
}
let blah = Blah.Move(direction: Direction.Right(distance: 10))
When I switch on the Blah enum I want to be able to conditionally switch on the Move.Right like this...
switch blah {
case .Move(let direction) where direction == .Right:
print(direction)
default:
print("")
}
But I get the error...
binary operator '==' cannot be applied to operands of type 'Direction' and '_'
Is there a way to do this?
case .Move(let direction) where direction == .Up:works just fine for me.Binary operator == cannot be applied to operands of type Direction and _with that. May be a clean and build problem though. I'll take a look thanks.distanceto the Direction then it goes wrong. Let me edit...