[swift-evolution] guard let x = x

Pyry Jahkola pyry.jahkola at iki.fi
Mon Oct 31 15:16:19 CDT 2016


> On 31 Oct 2016, Xiaodi Wu wrote:
> 
> 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.

You're right. I'd forgotten about that. I found out you can even place the `var` keyword inside a tuple pattern where only one variable is going to be modified locally:

    for (var i, c) in "foobar".characters.enumerated() {
      i += 1      // pretty contrived example
      print(i, c)
    }

— Pyry

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161031/b9f13abe/attachment.html>


More information about the swift-evolution mailing list