[swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)
Lance Parker
lance_parker at apple.com
Thu Nov 16 16:31:49 CST 2017
I dislike `mapSome` because, to me, it implies it will only pass the non-nil values of the sequence to the transformation closure.
`compactMap` isn’t an intuitive name, but I could get used to it. The thing I like about it is it could be paired with a `compacted` method that removes nils from the Sequence of optionals and returns a Sequence of non-optionals. If `compacted` is something that makes sense, then it would be nice if `compactMap` was just a merger of `map` and `compacted`. I would prefer to find a word other than compact that we could use here but I haven’t thought of one yet.
In isolation, I think that `filterMap` is best.
More information about the swift-evolution
mailing list