[swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

BJ Homer bjhomer at gmail.com
Mon Nov 20 11:22:39 CST 2017



> On Nov 20, 2017, at 10:09 AM, Drew Crawford via swift-evolution <swift-evolution at swift.org> wrote:
> 
> The typical case for this function in my code is the identity closure, that is
> 
>     let a: [Int?] = ...
>     print(a.filterMap {$0})
> 
> filterMap is quite poor for this situation because *each* component in the term is inaccurate:

filterMap is indeed an awkward name for this use case, just like flatMap is. In my experience, about half of my use cases use the identity closure, and half actually make use of the closure in a meaningful way. I would support a proposal to add something like Sequence.dropNils (actual name to be determined), and then we could let this proposal target the non-identity-closure use case.

-BJ

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171120/517c570c/attachment.html>


More information about the swift-evolution mailing list