[swift-evolution] [Proposal] Shorthand Argument Renaming

Thorsten Seitz tseitz42 at icloud.com
Wed Jun 1 00:08:37 CDT 2016


> Am 31.05.2016 um 10:14 schrieb Chris Williams via swift-evolution <swift-evolution at swift.org>:
> 
> Honestly what I’ve wanted for quite some time is just reasonable default parameter names. $0/$1… or any variation on index-based arguments is terrible for comprehension, and I feel like I’m being lazy and hurting whoever has to look at the code next every time I type out something like say <A [String: String]?.map { $0 } instead of .map{ key, value in key }.

So, just write the latter.

> If the Dictionary type’s map function could define “key” and “value” as parameter types it would go a long way in terms or readability, in my opinion.

The map function does not impose names on the arguments of the literal closure. You can choose them freely.

-Thorsten 


More information about the swift-evolution mailing list