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

Matt Gallagher mattxg at gmail.com
Wed Nov 15 23:29:16 CST 2017

My opinion is that filterMap is the right choice of name.

I'm completely biased, given that I already have a Swift library that uses filterMap, in exactly this context, for a Reactive Programming library:


Obviously, I went through the thought process, looked at other libraries and thought it was the best name.

On the topic of a method that "compacts" without also mapping... I think this encourages poor designs that should be using lazy transformations instead of aggregate processing. There is almost always a way around a bare flatten. The obvious quirkiness of `filterMap { $0 }` (or whatever the name ends up being) should be seen as a nudge to re-think the algorithm leading up to that point.

Matt Gallagher.

More information about the swift-evolution mailing list