This same issue applies to an Array of Arrays, wherein there is no renaming 
solution. That is, you've built a Collection of Collection, and have mixed up 
the inner and outer collections. I expect in most cases you'll run into a type 
error when you try to use the result.

This is an unfortunate bug to have, but I don't think a change to a core type 
is worth making over it. The name has been discussed in the past, and it was 
deemed sufficiently desirable as to defy standard naming conventions (it should 
be called mapped by standard conventions).

> On Dec 5, 2016, at 11:48 PM, David Sweeris via swift-evolution 
> <[email protected]> wrote:
> 
> 
>> On Dec 5, 2016, at 7:46 PM, Jay Zhao via swift-evolution 
>> <[email protected]> wrote:
>> 
>> Hi there,
>> 
>> Code explains everything:
>> 
>>      
>> 
>> /// Maybe a bad API naming in Swift? See below:
>> 
>>         /// array1 can be array of any object that have a `count` method
>>         let array1 = [[String]]()
>>         let array2 :[String]? = nil
>>         
>>         
>>         // I believe the confusion between `array.map` and 
>> `optionalArray.map` is really bad.
>>         // Because when you read code like this, you can not tell which is 
>> which:
>>         _ = array1.map({$0.count})
>>         _ = array2.map({$0.count})
>>         
>>         // It can be clearer:
>>         // 1, we pass `self.element` into the closure
>>         _ = array1.map({$0.count})
>>         // 2, we pass self directly into the closure
>>         _ = array2.mapMe({$0.count})
>> 
>> 
>> The mapFlat method is also problematic.
> 
> It might be possible to convince me to support renaming map for optionals, 
> but not to mapMe. As it is, you’ll have the same problem with anything having 
> a map function where the element(s) also have a map function. Sets of arrays, 
> arrays of dictionaries, etc. 
> 
> - Dave Sweeris
> _______________________________________________
> 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