I want this code to work.
I have an enumeration where the Direction.Right argument takes a distance parameter.
enum Direction { case Up case Down case Left case Right(distance: Int) }
Now another enumeration that can take a direction parameter.
enum Blah { case Move(direction: Direction) } let blah = Blah.Move(direction: Direction.Right(distance: 10))
When I turn on the Blah enum, I want to be able to conditionally enable Move.Right, like this ...
switch blah { case .Move(let direction) where direction == .Right: print(direction) default: print("") }
But I get an error ...
the binary operator '==' cannot be applied to operands of the type "Direction" and "_"
Is there any way to do this?
enums ios switch-statement swift
Fogmeister
source share