[swift-evolution] Add an ifPresent function to Optional
erica at ericasadun.com
Mon Mar 14 15:28:35 CDT 2016
> On Mar 14, 2016, at 2:18 PM, Daniel Vollmer via swift-evolution <swift-evolution at swift.org> wrote:
>> 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 don't quite see what advantage would that have. Could you elaborate?
There's precedent in map and flatMap for treating optionals this way.
> 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.
> swift-evolution mailing list
> swift-evolution at swift.org
More information about the swift-evolution