[swift-evolution] Add an ifPresent function to Optional

Andrey Tarantsov andrey at tarantsov.com
Sun Mar 20 12:22:49 CDT 2016

> No.  My argument is that map on collections and on optionals are two
> completely different things.  They unify on a level that does not
> exist in Swift (higher-kinded types).


Optional.map is already highly unfortunate. It makes optional arrays especially painful to deal with, but even in general, you can no longer glance at the code and see which parts are dealing with many items and which parts are dealing with single items.

I would definitely support renaming Optional.{map,flatMap}.


More information about the swift-evolution mailing list