[swift-evolution] Deprecating Trailing Closures

Brent Royal-Gordon brent at architechies.com
Fri Mar 25 07:44:46 CDT 2016


>>     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 })

I, on the other hand, cannot imagine how you would not see a difference between the two. The paren-less form is *far* more readable to me; when you put a parenthesis and a curly bracket next to each other, the curly bracket disappears and I can no longer see that the expression is a closure.

Swift generally doesn't mandate any particular style. I think this is a good time to continue that tradition.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list