[swift-evolution] [Proposal] Allow using optional binding to upgrade self from a weak to strong reference

Kurt Werle kurt at circlew.org
Sat Feb 20 00:15:50 CST 2016


On Fri, Feb 19, 2016 at 9:04 PM, Evan Maloney <emaloney at gilt.com> wrote:

...

> With this feature, the code above could be rewritten as:
>
> networkRequest.fetchData() { [weak self] result in
>     guard let self = self else { return }
>
> If you're going to have boilerplate like that, then the following seems
like it accomplishes the same thing [in this specific case] without
changing anything:

networkRequest.fetchData() { [unowned self] result in
>     guard self != nil else { return }
>
>
Kurt
-- 
kurt at CircleW.org
http://www.CircleW.org/kurt/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160219/4c199f4f/attachment.html>


More information about the swift-evolution mailing list