<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">Am 08.11.2017 um 19:23 schrieb Kevin Ballard via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt;:</div><br class="Apple-interchange-newline"><div class="">


<title class=""></title>

<div class=""><div class="">On Tue, Nov 7, 2017, at 05:23 PM, Tino Heth via swift-evolution wrote:<br class=""></div>
<blockquote type="cite" class=""><div class="">-1<br class=""></div>
<div class=""><br class=""></div>
<div class="">I guess breaking existing code will be the show stopper for this proposal — but I generally think that compatibility is a poor rationale to stop an improvement, so my personal reasons are different:<br class=""></div>
<div class="">The name is just wrong.<br class=""></div>
<div class="">Just have a look at this simple example<br class=""></div>
<div class=""><br class=""></div>
<div class=""><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-stretch:normal;line-height:normal;font-family:Menlo;color:rgb(186, 45, 162);background-color:rgb(255, 255, 255);" class=""><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-stretch:normal;line-height:normal;" class=""><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-stretch:normal;line-height:normal;" class="">extension<span class="colour" style="">&nbsp;</span><span class="colour" style="color:rgb(112, 61, 170)">Int</span><span class="colour" style="">&nbsp;{</span><br class=""></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">&nbsp; &nbsp;&nbsp;<span class="colour" style="color:rgb(186, 45, 162)">func</span>&nbsp;justImagineError()&nbsp;<span class="colour" style="color:rgb(186, 45, 162)">throws</span>&nbsp;-&gt;&nbsp;<span class="colour" style="color:rgb(112, 61, 170)">Int</span>&nbsp;{<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-stretch:normal;line-height:normal;" class=""><span class="colour" style="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span>return<span class="colour" style="">&nbsp;</span>self<br class=""></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">&nbsp; &nbsp;&nbsp;}<br class=""></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">}<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-stretch:normal;line-height:normal;font-family:Helvetica;min-height:14px;" class=""><br class=""></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span class="colour" style="color:rgb(186, 45, 162)">let</span>&nbsp;ints: [<span class="colour" style="color:rgb(112, 61, 170)">Int</span>?] = [<span class="colour" style="color:rgb(186, 45, 162)">nil</span>]<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-stretch:normal;line-height:normal;font-family:Helvetica;min-height:14px;" class=""><br class=""></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span class="colour" style="color:rgb(186, 45, 162)">let</span>&nbsp;result =&nbsp;<span class="colour" style="color:rgb(79, 129, 135)">ints</span>.<span class="colour" style="color:rgb(62, 30, 129)">flatMap</span>&nbsp;{<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-stretch:normal;line-height:normal;color:rgb(49, 89, 93);" class=""><span class="colour" style="">&nbsp; &nbsp;&nbsp;</span><span class="colour" style="color:rgb(186, 45, 162)">return</span><span class="colour" style="">&nbsp;</span><span class="colour" style="color:rgb(186, 45, 162)">try</span><span class="colour" style="">? $0?.</span>justImagineError<span class="colour" style="">()</span><br class=""></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">}<br class=""></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-stretch:normal;line-height:normal;color:rgb(79, 129, 135);" class=""><span class="colour" style="color:rgb(62, 30, 129)">print</span><span class="colour" style="">(</span>result<span class="colour" style="">)</span><br class=""></div>
<div class=""><span class="colour" style=""></span><br class=""></div>
</div>
</div>
</div>
<div class="">If flatMap would really filter out nil values, this should yield an empty array as result — but the actual output is&nbsp;<b style="font-family:Menlo;" class="">[nil]</b><br class=""></div>
</blockquote><div class=""><br class=""></div>
<div class="">flatMap does filter out nil values. The problem is the return type of your block is `Int??`, not `Int?`, so it's stripping off the outer layer of optionals.</div></div></div></blockquote>The filter function afaik doesn’t perform that kind of stripping - if you feed it [A?], you get [A?] as output, no matter what kind of predicate you use, it can only eliminate values (Optional.none), not change their type.</div></body></html>