[swift-evolution] [Proposal] Allow upgrading weak self to strong self by assignment

plx plxswift at icloud.com
Fri Feb 19 13:30:37 CST 2016


Really quickly:

> The following would also be legal:
> networkRequest.fetchData() { [weak self] result in
>     if let self = self {
>         switch result {
>         case .Succeeded(let data):
>             self.processData(data)
> 
>         case .Failed(let err):
>             self.handleError(err)
>         }
>     }
> }
> As would this:
> 
> networkRequest.fetchData() { [weak self] result in
>     guard self != nil else { return }
> 
>     let self = self!
…isn’t there a race condition in this example (admittedly an *unlikely* one in most settings, but still…)?


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


More information about the swift-evolution mailing list