[swift-evolution] Allowing `guard let self = self else { ... }` for weakly captured self in a closure.

Greg Parker gparker at apple.com
Tue Jan 5 22:34:04 CST 2016


Does further use of self after that actually use a strong shadowing variable? Or does it go back to the weak reference it already had as if the shadow were not there?

> On Jan 5, 2016, at 8:26 PM, Jacob Bandes-Storch via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Wow! I didn't know that worked. It's a bit surprising, and perhaps not intended. I think the proposal is still valid.
> 
> On Tue, Jan 5, 2016 at 8:21 PM, Christopher Rogers <christorogers at gmail.com <mailto:christorogers at gmail.com>> wrote:
> You can shadow self with a guard like you wrote it if use the keyword escaping backquotes like so:
> 
> guard let `self` = self else { return }


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


More information about the swift-evolution mailing list