[swift-evolution] [Draft Proposal] A simplified notation for avoiding the weak/strong dance with closure capture lists

Kurt Werle kurt at circlew.org
Mon Feb 8 13:34:03 CST 2016


On Sun, Feb 7, 2016 at 11:05 AM, Kenny Leung via swift-evolution <
swift-evolution at swift.org> wrote:

> I propose
>
> doit { [weak self, other]? in
>     doing some stuff...
> }
>
> If any of the capture list evaluates to nil, the block is not executed. If
> the block signature has an optional return value, nil is returned. Anything
> else, you’re on your own.


On reflection, I have to say that I like this solution best.  It is very
similar in flavor to

maybeNilObject?.someMethod()

I might even argue that it should only be used for Void return types, just
like that method call becomes essentially void if the object is nil.

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/20160208/471ad559/attachment.html>


More information about the swift-evolution mailing list