<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="">On Nov 11, 2017, at 9:49 AM, Michel Fortin via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><div class=""><div class=""><div class=""><br class=""></div><div class="">I think it fits well for arrays. Not sure about optionals.</div></div></div></div></div></div></blockquote></div><br class=""><div class="">This proposal only suggests changing the one on sequences, and even then, not all of them. Currently, the following exist:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class="">// Reminder: Int("someString") returns 'Int?' in the following examples</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">// (1) Sequence.flatMap() with a closure returning an optional, dropping anything that maps to nil</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(0, 0, 0);" class="">[<span style="color: #d12f1b" class="">"1"</span>, <span style="color: #d12f1b" class="">"mountain"</span>, <span style="color: #d12f1b" class="">"2"</span>].<span style="color: #3e1e81" class="">flatMap</span>({ <span style="color: #703daa" class="">Int</span>($0) }) <span style="color: #008400" class="">// [1, 2]</span></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">// (2) Sequence.flatMap() with a closure returning a sequence, then joining (“flattening”) them into one array</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(0, 0, 0);" class="">[<span style="color: #272ad8" class="">1</span>, <span style="color: #272ad8" class="">2</span>, <span style="color: #272ad8" class="">3</span>].<span style="color: #3e1e81" class="">flatMap</span>({ <span style="color: #703daa" class="">Array</span>(<span style="color: #272ad8" class="">1</span>...$0) }) <span style="color: #008400" class="">// [1, 1, 2, 1, 2, 3]</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="color: #008400" class=""><br class=""></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">// (3) Optional.flatMap() with a closure returning an optional, flattening a nested optional.</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(0, 0, 0);" class="">(<span style="color: #d12f1b" class="">"3"</span> <span style="color: #ba2da2" class="">as</span> <span style="color: #703daa" class="">String</span>?).<span style="color: #3e1e81" class="">flatMap</span>({ <span style="color: #703daa" class="">Int</span>($0) }) <span style="color: #008400" class="">// Optional(3)</span></div><div class=""><span style="color: #008400" class=""><br class=""></span></div></div></div><div class=""><br class=""></div><div class="">The 2nd and 3rd variants are both about flattening nested structures, and would not change under this proposal. We would keep calling them “<font face="Menlo" class="">flatMap()</font>”. There is no a proposal to add <font face="Menlo" class="">Optional.filterMap</font>, nor to change the <font face="Menlo" class="">Sequence.flatMap</font> variant that flattens nested sequences. The only change proposed it is to rename the first one.</div><div class=""><br class=""></div><div class="">-BJ</div></body></html>