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

About forEach: Apparently, early versions of Swift didn't have it. Why it was added is unclear to me. That said, back then, you did have to write _ = even when the return value was Void, and I wonder if that was part of the issue. Chris Eidhof, both on this list and in Advanced Swift, has argued against using forEach. So, I wouldn't say that there's general agreement as to the role of forEach in Swift. But on the flip side, I guess using map in the same role is rather controversial.

1 Like