<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></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="">Le 16 nov. 2017 à 11:06, Brent Royal-Gordon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class="">On Nov 15, 2017, at 4:36 PM, Greg Parker 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=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">"compactMap" is okay if "compact" is added. Is "compact" a common enough operation in practice to pull its own weight?</div></div></blockquote><br class=""></div><div class="">Lines containing code like `flatMap { $0 }`—which could be compacting optionals or flattening nested sequences—appear 89 times in the source compatibility suite. (I happen to have it on my hard drive right now.)</div><div class=""><br class=""></div><div class="">My main concern about adding a compacting method is…well, am I missing a better implementation than the slightly gross one I cooked up in a playground just now?</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>protocol&nbsp;_OptionalProtocol {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>&nbsp; &nbsp;&nbsp;associatedtype&nbsp;_Wrapped<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>&nbsp; &nbsp;&nbsp;var&nbsp;_optional:&nbsp;_Wrapped? {&nbsp;get&nbsp;}<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>}<br class=""></div></div></div></blockquote></div><div class=""><br class=""></div><div class="">Welcome to the club :-) <a href="https://github.com/search?q=OptionalProtocol+language%3Aswift&amp;type=Code&amp;utf8=✓" class="">https://github.com/search?q=OptionalProtocol+language%3Aswift&amp;type=Code&amp;utf8=✓</a></div><div class=""><br class=""></div><div class="">Gwendal</div><div class=""><br class=""></div></body></html>