Generally I'm in favor of something like this.

But if "case" is removed, doesn't that introduce an ambiguity? In an
admittedly contrived pathological case, you could have an "=" operator
which returns a Bool; then "if .someCase = myvar" would be ambiguous.

Jacob

On Sun, May 1, 2016 at 1:12 AM, Антон Жилин <swift-evolution@swift.org>
wrote:

> Generally, pattern binding in `if` looks like this:
>
> if case *pattern* = *expression* { ... }
>
> Pattern binding for optionals is currently usable as both of:
>
> if case let .some(x) = y { ... }
> if case let x? = y { ... }
>
> Now, there is also an older optional-specific hack:
>
> if let x = y { ... }
>
> In terms of pattern binding, it should always be true, and it's illogical
> inside `if`.
>
> I suggest:
> 1) Remove optional pattern binding
> 2) Remove `case` in `if` pattern binding
>
> Really, `case` should be an attribute of `switch`, not `if`.
>
> Pattern binding for optionals will look like:
>
> if let x? = y { ... }
>
> It will become more explicit and consistent with the rest of the language.
>
> We need to hurry until Swift 3 lands!
>
> - Anton
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to