>> guard let (a, b, c) = (opt1, opt2, opt3) else { ... }
>
> You mention `guard case` in the motivation, but I think for the uninitiated
> reader it would be fair to point out that the following example already works
> equivalently, with only a few extra characters:
>
> guard case let (a?, b?, c?) = (opt1, opt2, opt3) else { ... }
It seems fair to mention that, so I've added it to the "Alternatives
Considered" entry for doing nothing.
Not accepting this proposal
This proposal does not add new functionality; it merely removes keyword
clutter. However, it offers a convenient replacement for a commonly-used
feature which has just been removed as a result of grammatical ambiguity, not
user confusion or lack of utility.
The same functionality is also available through case conditions:
guard case let (a?, b?, c?) = (opt1, opt2, opt3) else { ... }
However, all of optional binding is redundant with case conditions; we keep it
anyway because it's a convenient shorthand and saves beginners from having to
learn about pattern matching. Multiple bindings are a natural fit for the
subset of case features available through optional binding.
--
Brent Royal-Gordon
Architechies
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution