<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 16, 2015, at 0:03 , Dave Abrahams via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 15, 2015, at 7:21 PM, Rob Mayoff via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"></blockquote><blockquote type="cite" class="">Dmitri wrote:</blockquote><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class=""><div class="">What's the advantage?&nbsp; Why would we want to have a type that is isomorphic to Optional, except that conforms to CollectionType?<br class=""></div></span></div></div></div></blockquote><div class=""><br class=""></div><div class="">My question (apologies if it has been answered already) is: Why isn't Optional a CollectionType, like it is in Scala?</div></div></div></div></div></blockquote><br class=""></div><div class="">I don't remember the rationale, but it&nbsp;<a href="https://github.com/apple/swift/commit/fad874708e05cff56aec5587a4b0f49cdadc6d11" class="">used to be that way</a>&nbsp;and during the run-up to the Swift 1 release IIRC several members of the Swift team objected to it. &nbsp;That's the answer to Dmitri's question: I have considered that to be off the table, but we could revisit it. &nbsp;</div><div class=""><br class=""></div><div class="">One cute effect, which might be too cute for some, is that</div><div class=""><br class=""></div><div class="">&nbsp; if let x = y { &nbsp;... }&nbsp;</div><div class=""><br class=""></div><div class="">becomes equivalent to</div><div class=""><br class=""></div><div class="">&nbsp; for x in y { ... }</div><div class=""><br class=""></div>when y is an optional.</div></div></blockquote></div><br class=""><div class="">IIRC we made it a CollectionType purely so we could use "for x in y" while "if let x = y" was being implemented. We didn't actually consider it properly.</div><div class=""><br class=""></div><div class="">Dmitri has mentioned at times that he's concerned about the implicit conversion to Optional kicking in when the contextual type is "T: CollectionType", but I don't think that would actually happen. We don't try random implicit conversions, only the ones that there's context for. But someone would need to verify that.</div><div class=""><br class=""></div><div class="">Jordan</div></body></html>