<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="">Oh right. I guess that makes most of my review beside the point then. Sorry.<div class=""><div class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">Le 11 nov. 2017 à 14:46, BJ Homer <<a href="mailto:bjhomer@gmail.com" class="">bjhomer@gmail.com</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><br class=""><div class=""><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 class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><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 class="" 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);">// Reminder: Int("someString") returns 'Int?' in the following examples</div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div></div><div class=""><div class="" 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);"><div class="" style="margin: 0px; font-stretch: normal; line-height: normal;">// (1) Sequence.flatMap() with a closure returning an optional, dropping anything that maps to nil</div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal;">[<span class="" style="color: rgb(209, 47, 27);">"1"</span>, <span class="" style="color: rgb(209, 47, 27);">"mountain"</span>, <span class="" style="color: rgb(209, 47, 27);">"2"</span>].<span class="" style="color: rgb(62, 30, 129);">flatMap</span>({ <span class="" style="color: rgb(112, 61, 170);">Int</span>($0) }) <span class="">// [1, 2]</span></div><div class="" style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Helvetica; min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal;">// (2) Sequence.flatMap() with a closure returning a sequence, then joining (“flattening”) them into one array</div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal;">[<span class="" style="color: rgb(39, 42, 216);">1</span>, <span class="" style="color: rgb(39, 42, 216);">2</span>, <span class="" style="color: rgb(39, 42, 216);">3</span>].<span class="" style="color: rgb(62, 30, 129);">flatMap</span>({ <span class="" style="color: rgb(112, 61, 170);">Array</span>(<span class="" style="color: rgb(39, 42, 216);">1</span>...$0) }) <span class="">// [1, 1, 2, 1, 2, 3]</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal;"><span class=""><br class=""></span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal;">// (3) Optional.flatMap() with a closure returning an optional, flattening a nested optional.</div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal;">(<span class="" style="color: rgb(209, 47, 27);">"3"</span> <span class="" style="color: rgb(186, 45, 162);">as</span> <span class="" style="color: rgb(112, 61, 170);">String</span>?).<span class="" style="color: rgb(62, 30, 129);">flatMap</span>({ <span class="" style="color: rgb(112, 61, 170);">Int</span>($0) }) <span class="">// Optional(3)</span></div><div class=""><span 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></div></div></blockquote></div><br class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div class="" style="font-family: Helvetica; font-variant-ligatures: normal; font-variant-east-asian: normal; font-variant-position: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><span class="Apple-style-span" style="border-collapse: separate; font-variant-ligatures: normal; font-variant-east-asian: normal; font-variant-position: normal; line-height: normal; border-spacing: 0px;"><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><span class="Apple-style-span" style="border-collapse: separate; font-variant-ligatures: normal; font-variant-east-asian: normal; font-variant-position: normal; line-height: normal; text-align: -webkit-auto; border-spacing: 0px;"><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><span class="Apple-style-span" style="border-collapse: separate; font-variant-ligatures: normal; font-variant-east-asian: normal; font-variant-position: normal; line-height: normal; text-align: -webkit-auto; border-spacing: 0px;"><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">-- <br class="">Michel Fortin</div><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><span class="" style="text-align: -webkit-auto;"><a href="https://michelf.ca/" class="">https://michelf.ca</a></span></div><div class=""><br class=""></div></span></div></span></div></span></div></div></div></div></div></div></div></div></body></html>