In swift, the if syntax only allows me to execute statements if the variable is of a specific type. for instance
class A {...} class B: A {...} class C: A {...} func foo(thing: A) { if let b = thing as? B {
Is this possible with the switch statement?
I got this far, but the variables b and c are still of type A, and not cast from B and C:
func foo(thing: A) { switch thing { case let b where b is B: // do something case let c where c is C: // do something else default: // do something else: } }
Okapi source share