[swift-evolution] Unable to do unnamed binding in swift

Dave Abrahams dabrahams at apple.com
Mon Feb 8 06:36:59 CST 2016


on Mon Feb 08 2016, James Campbell <swift-evolution at swift.org> wrote:

> In Swift 2.1 its possible to do the following:
>
> if let _ = userInfo["msgIdenitifer"] where application.applicationState == .
> Active {
>
> //Do something
>
>  }
>
> But not:
>
> switch(userInfo)
>
> {
>
> case let _ = userInfo["msgIdenitifer"] where application.applicationState
> == .Active:
>
> //do something
>
> break
>
> }

THat's correct.  In a switch you'd need full pattern-matching syntax,
e.g.

    case let unwrappedUserInfo? where application.application == .Active:

and you can't do an assignment right there.

perhaps you meant to switch(userInfo["msgIdenitifer"])

?

-- 
-Dave



More information about the swift-evolution mailing list