+1 for being able to use cars.map(make)

> Am 16.12.2015 um 16:23 schrieb Al Skipp via swift-evolution 
> <[email protected]>:
> 
>> On 16 Dec 2015, at 12:47, Sean Kosanovich via swift-evolution 
>> <[email protected]> wrote:
>> 
>> As a Groovy user, I really enjoy the shorthand Spread Operator over the 
>> Collect Closure (Map is the equivalent in Swift).
>> 
>> Consider the following Swift code:
>> 
>> struct Car {
>>     let make: String
>>     let model: String
>> }
>> 
>> let cars = [Car(make: "Jeep", model: "Grand Cherokee"), Car(make: "Dodge", 
>> model: "Challenger")]
>> let makes = cars.map() { $0.make }
>> 
>>  
>> 
>> Now consider the same code using a Spread Operator:
>> 
>> let makes = cars*.make
> 
> I think there is a tension in Swift between its object oriented nature and 
> higher-order functions which leads to a lot of repetition of { $0.property }
> 
> In this example:
> cars.map { $0.make }
> 
> I’d like to write the following, but ‘make’ is a member, not a free function:
> cars.map(make)
> 
> Is anyone else irked by the preponderance of { $0.property } in Swift (or is 
> it just me being grumpy)? Not sure what the solution would be, but I can’t 
> say I’m keen on the suggestion of:
> 
> cars*.make
> 
> It’s too mysterious.
> 
> _______________________________________________
> 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

Reply via email to