[swift-evolution] Add an ifPresent function to Optional

Daniel Vollmer lists at maven.de
Mon Mar 14 15:18:20 CDT 2016


> On 13 Mar 2016, at 18:04, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
> I am in favour of making optionals consistently act like 1-item-max collections.

Why stop there? Why not make all non-optionals collections of one?

I’m not convinced that making optionals conform to CollectionType actually improves matters: Yes, it may make the odd use here or there slightly more convenient, but at the cost of clarity IMO: Optionals have largely different set of concerns than collections, and having them suddenly inherit all CollectionType functionality and extensions doesn’t make their use (if it relies on them) any clearer, it obscures their “Optional”-ness instead.


More information about the swift-evolution mailing list