We've talked about this before, so I'm going to link directly to my (negative) 
response from back then: 
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003697.html.

(The rest of the thread is certainly also relevant, but my past opinion is 
still the one I most identify with here!)

Jordan

> On Mar 11, 2016, at 12:15 , Dave via swift-evolution 
> <[email protected]> wrote:
> 
> +1.
> 
> I’d go so far as to suggest that maybe Optional should conform to 
> CollectionProtocol, since you can pretty easily think of an Optional as a 
> collection that can’t have more than one element.
> 
> - Dave Sweeris
> 
>> On Mar 10, 2016, at 7:32 PM, Erica Sadun via swift-evolution 
>> <[email protected] <mailto:[email protected]>> wrote:
>> 
>> While I'm not convinced of the utility or lack thereof, wouldn't it make 
>> more sense 
>> to extend `forEach` to support optionals in a similar way that map and 
>> flapMap 
>> currently do rather than introduce `ifPresent`?
>> 
>> let y: Int? = 1
>> let n: Int? = nil
>> 
>> _ = y.map({ print($0) }) // works in current Swift
>> _ = n.map({ print($0) }) // ditto
>> 
>> y.forEach{ print($0) } // not currently a thing
>> n.forEach{ print($0) } // ditto
>> 
>> Just spitballing here.
>> 
>> -- E
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> [email protected] <mailto:[email protected]>
>> https://lists.swift.org/mailman/listinfo/swift-evolution 
>> <https://lists.swift.org/mailman/listinfo/swift-evolution>
> _______________________________________________
> swift-evolution mailing list
> [email protected] <mailto:[email protected]>
> https://lists.swift.org/mailman/listinfo/swift-evolution 
> <https://lists.swift.org/mailman/listinfo/swift-evolution>
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to