[swift-evolution] Deprecating Trailing Closures
Haravikk
swift-evolution at haravikk.me
Fri Mar 25 03:10:29 CDT 2016
> On 24 Mar 2016, at 21:08, Howard Lovatt <howard.lovatt at gmail.com> wrote:
>
> I use trailing closures all the time because I find the brackets too noisy, like ; at the end of a line is too noisy. The sort of code I use is:
>
> let foo = myArray
> .filter { $0 & 1 == 1 }
> .map { $0 + 1 }
> .reduce(0) { $0 + $1 }
This doesn’t really seem much neater or more readable to me than:
let foo = myArray
.filter({ $0 & 1 == 1 })
.map({ $0 + 1 })
.reduce(0, { $0 + $1 })
While they may add a small amount of noise, in the latter case the parenthesis clarifies that each is a method, and what all of its arguments are, and don’t use any custom syntax. Of course this assumes that .reduce() would have an optional label on its closure argument.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160325/611a0481/attachment.html>
More information about the swift-evolution
mailing list