Add `filter` and `ifSome(then:)` to Optional

What happened with this pitch?

Can we spin-off at least the non-controversial Optional.filter and drive that through SE proposal?

It may be more productive to file a bug report to request new features.

Forgot about it, and I don't have time to cook up a proposal this week.

Let’s see if this has any legs then…

Nope. @jrose said:

API additions always go through the Swift Evolution process.

@AlexanderM would you be fine with splitting out just the filter into its own proposal? Do you have time to do that?

BTW, this optional filter pattern is all over the SE-0222 that’s currently in review.

Finally made a proposal for this: API Additions to Optional (filter, ifSome, ifNone, peek)

Your ifSome is exactly equivalent to the existing Optional.map.

1 Like