[swift-evolution] [Review] Add a Lazy flatMap for Sequences of Optionals
Dave Abrahams
dabrahams at apple.com
Wed Dec 16 02:03:32 CST 2015
> On Dec 15, 2015, at 7:21 PM, Rob Mayoff via swift-evolution <swift-evolution at swift.org> wrote:
>
> Dmitri wrote:
> What's the advantage? Why would we want to have a type that is isomorphic to Optional, except that conforms to CollectionType?
>
> My question (apologies if it has been answered already) is: Why isn't Optional a CollectionType, like it is in Scala?
I don't remember the rationale, but it used to be that way <https://github.com/apple/swift/commit/fad874708e05cff56aec5587a4b0f49cdadc6d11> and during the run-up to the Swift 1 release IIRC several members of the Swift team objected to it. That's the answer to Dmitri's question: I have considered that to be off the table, but we could revisit it.
One cute effect, which might be too cute for some, is that
if let x = y { ... }
becomes equivalent to
for x in y { ... }
when y is an optional.
-Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151216/dcbca3a9/attachment.html>
More information about the swift-evolution
mailing list