<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=""><div><blockquote type="cite" class=""><div class="">On Nov 8, 2017, at 3:20 PM, Tino Heth via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><div 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=""><span 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; float: none; display: inline !important;" class="">This is a wonderful example! But it’s an argument for a different discussion (of general usefulness of implicit optional promotion). Thanks to the optional promotion, what the closure returns is not nil, but instead is .some(nil), and that is not filtered out.</span></div></blockquote></div>My point is: The proposed filterMap isn’t a combination of map and filter at all — or can you build it just out of map &amp; filter, like flatMap is constructed from map &amp; flatten?</div></div></blockquote><div><br class=""></div>You can built it out of map and filter:</div><div><br class=""></div><div>&nbsp; func filterMap&lt;T&gt;(_ fn: (Element) -&gt; U?) -&gt; [U] {</div><div>&nbsp; &nbsp; return map(fn).filter { $0 != nil }.map { $0! }</div><div>&nbsp; }</div><div><br class=""></div><div>John.</div></body></html>