[swift-evolution] guard let x = x
Xiaodi Wu
xiaodi.wu at gmail.com
Mon Oct 31 15:05:14 CDT 2016
Don't we currently have "for x in y" and "for var x in y"? So, we could
have "unwrap x" and "unwrap var x".
And since unwrap wouldn't allow arbitrary Boolean expressions at the front
like if and guard statements do, it could use the where clause like for
loops do.
On Mon, Oct 31, 2016 at 14:58 Pyry Jahkola <pyry.jahkola at iki.fi> wrote:
>
> On 31 Oct 2016, Xiaodi Wu wrote:
>
> An alternative that would seem to satisfy some objections is to have a
> distinct "unwrap" statement--as in: "unwrap x else { ... }".
>
>
> True. The `*let*`, on the other hand, has the minor upside that it's
> naturally substituted with `*var*` where in-place mutation is needed:
>
> *guard let* value, *var* collection *else* { ... }
> collection.append(value)
> // ...
>
> Disclaimer: I don't know if this is a realistic usage scenario but it
> seems more natural to Swift, in my view.
>
> — Pyry
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161031/1d9aae29/attachment.html>
More information about the swift-evolution
mailing list