The switch statement in Swift is so much more expressive. I\'m wondering if this might be possible:
Lets look at UIViewAutoresizing for example. It\'s defined in Objecti
You definitely can, although it's a little more convoluted now that RawOptionSetType
doesn't implement the BooleanType
protocol.
switch foo {
case let x where x & .FlexibleHeight != nil:
println("height")
case let x where x & .FlexibleWidth != nil:
println("width")
case let x where x & .FlexibleTopMargin != nil:
println("top margin")
default:
println("no")
}
Note that this stops on the first condition that matches! So it really is another form of this:
if foo & .FlexibleHeight != nil {
println("height")
} else if foo & .FlexibleWidth != nil {
println("width")
} else if foo & .FlexibleTopMargin != nil {
println("top margin")
}