<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><blockquote type="cite" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class="">Optional.map and Array.map do different things, and unifying them seems harmful.<br class=""></blockquote><br class="">They actually don’t do different things. Optional can be thought of as an array of zero or one elements; from that point of view,&nbsp;operations like `map` and `flatMap` which are supported on both actually do the same thing.<br class=""></blockquote><br class="">I understand that reasoning, but it's completely contrary to how I (and presumably many other people) normally think. To me,&nbsp;optional is not a 0..1 array, it's just an optional. </blockquote><br class=""><blockquote type="cite" class="">I don't want a flatMap on optionals (which, I believe, was thankfully removed in Swift&nbsp;2).<br class=""></blockquote><div class=""><br class=""></div>Thankfully it lives : )<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);" class="">// useless function: return arg if less than 10, otherwise .None</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> f(x:<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span>) -&gt; <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span>? {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">&nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> x &lt; <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">10</span> ? x : .<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">None</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px;" class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);" class="">Int</span><span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 11px;" class="">(</span><span style="font-family: Menlo; font-size: 11px; color: rgb(209, 47, 27);" class="">"9"</span><span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 11px;" class="">).</span><span style="font-family: Menlo; font-size: 11px; color: rgb(61, 29, 129);" class="">map</span><span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 11px;" class="">(</span><span style="font-family: Menlo; font-size: 11px; color: rgb(49, 89, 93);" class="">f</span><span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 11px;" class="">)</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;// .Some(.Some(9))</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(61, 29, 129);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="color: rgb(209, 47, 27);" class="">"9"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">).</span>flatMap<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">f</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">) // .Some(9)</span></div></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(61, 29, 129);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><br class=""></span></div><div style="margin: 0px;" class=""><div style="margin: 0px;" class=""><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Int</span><span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 11px;" class="">(</span><span style="color: rgb(209, 47, 27); font-family: Menlo; font-size: 11px;" class="">"</span><font color="#d12f1b" face="Menlo" class=""><span style="font-size: 11px;" class="">10"</span></font><span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 11px;" class="">).</span><span style="color: rgb(61, 29, 129); font-family: Menlo; font-size: 11px;" class="">map</span><span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 11px;" class="">(</span><span style="color: rgb(49, 89, 93); font-family: Menlo; font-size: 11px;" class="">f</span><span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 11px;" class="">)</span><span style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 11px;" class="">&nbsp;// .Some(.None)</span></div><div style="margin: 0px;" class=""><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">Int</span><span style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 11px;" class="">(</span><span style="color: rgb(209, 47, 27); font-family: Menlo; font-size: 11px;" class="">"</span><font color="#d12f1b" face="Menlo" class=""><span style="font-size: 11px;" class="">10"</span></font><span style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 11px;" class="">).</span><font color="#3d1d81" face="Menlo" class=""><span style="font-size: 11px;" class="">flatMap</span></font><span style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 11px;" class="">(</span><span style="color: rgb(49, 89, 93); font-family: Menlo; font-size: 11px;" class="">f</span><span style="color: rgb(0, 0, 0); font-family: Menlo; font-size: 11px;" class="">) // .None</span></div></div></body></html>