Or maybe just: mapUnwrapped
···
On 6 Dec 2016, at 11:46, Jay Zhao <zhaojianyin@icloud.com> 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.
Yours,
Jay Zhao