<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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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 _OptionalProtocol {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span> associatedtype _Wrapped<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span> var _optional: _Wrapped? { get }<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&type=Code&utf8=✓" class="">https://github.com/search?q=OptionalProtocol+language%3Aswift&type=Code&utf8=✓</a></div><div class=""><br class=""></div><div class="">Gwendal</div><div class=""><br class=""></div></body></html>