swift2 - Can't match on enum without using value -
i've updated project use swift 2. i've come across silly situation switches. here's simple example.
enum x { case asint(int) case asbool(bool) } g() -> x { // ... } f() -> bool { let local = g(); switch local { case .asint(let x) return true; case .asbool(let bool) return false; } }
the swift compiler complains (warning) x
unused, is. tells me replace _
. fine, replaced _
. swift compiler complains (warning) let
binding binds no variables. fine, removed it. swift compiler throws error complaining tuple pattern doesn't match.
how match on enum without using value or getting bunch of pointless warnings/errrors recommended fix not fix anything?
func f() -> bool { switch g() { case .asint: return true case .asbool: return false } }
Comments
Post a Comment