I have the following code:
class Base {}
class A: Base {}
class B: Base {}
class C: Base {}
func next(obj: Base) -> Base {
if obj is A { return B() }
else if obj is B { return C() }
else if obj is C { return A() }
else { return A() }
}
How do I express the chained if
s as a single switch
statement instead?