[swift-evolution] [Pitch] inout with capture variable

Daniel Resnick danielzresnick at gmail.com
Wed Oct 5 23:28:48 CDT 2016


You can currently achieve the same result if you remove `[inout a]` since
`var`s are captured by reference.

On Wed, Oct 5, 2016 at 9:06 PM, Cao Jiannan via swift-evolution <
swift-evolution at swift.org> wrote:

> for example:
>
> var a = 1
>
> let block = { [inout a] in
>         a += 1
> }
>
> block()
> block()
>
> print(a) // 3
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161005/79f7fe58/attachment.html>


More information about the swift-evolution mailing list