> I'm a big fan of this, or something like this, but the core team has rejected
> proposals like this before. They apparently believe that it would be
> difficult to tell how much of the expression you intended to make a closure
> of:
>
> let neg = [1, -2, 3].map(-{ abs($0) })
> let neg = [1, -2, 3].map({ -abs($0) })
> let neg = { [1, -2, 3].map(-abs($0)) }
I believe that in Scala (which has this feature), the entire content of the
parenthesis is the statement and you need to use the placeholder (_ in Scala,
$0 in Swift) to indicate it's a closure and not something else.
I've never been a fan of this as I don't think it improves readability, mostly
when you start nesting stuff like:
array.map($0.tranform($0.uppercaseString))
which seems incredibly confusing.
> And believe that this syntax is limited in important ways, like being unable
> to reorder parameters. They think that closures with $N are more explicit and
> flexible while only requiring a little bit more code.
>
> --
> Brent Royal-Gordon
> Architechies
>
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution