<div dir="ltr">On Mon, Oct 23, 2017 at 6:11 PM, Braden Scothern <span dir="ltr">&lt;<a href="mailto:bradenscothern@gmail.com" target="_blank">bradenscothern@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The reason `flatMap(_:)` has its name is for code like this:<div><br></div><div>```</div><div><font face="monospace, monospace">    let nestedArray = [[1, 2, 3], [4, 5, 6]]</font></div><div><font face="monospace, monospace">    let flatArray = nestedArray.flatMap {</font></div><div><font face="monospace, monospace">        $0</font></div><div><font face="monospace, monospace">    }</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">    print(flatArray) // prints </font><span style="font-family:monospace,monospace">[1, 2, 3, 4, 5, 6]</span></div><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace">    let anotherNestedArrays = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]</span></div><div><span style="font-family:monospace,monospace">    let anotherFlatArray = anotherNestedArray.flatMap {</span></div><div><span style="font-family:monospace,monospace">        $0</span></div><div><span style="font-family:monospace,monospace">    }</span></div><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace">    print(anotherFlatArray) // prints [[1, 2], [3, 4], [5, 6], [7, 8]]</span></div><div>```</div><div><br></div><div>Do your examples from other languages have this behavior of flattening nested sequences by 1 layer? Do you think it makes sense to have this effect as part of your proposed rename?</div><div><br></div><div>I feel like the name `filteredMap(_:)` implies that the result should keep the same structure as the original Sequence type which doesn&#39;t allow for the flattening.</div><div><br></div><div>If these 2 pieces of functionality weren&#39;t already a part of one function or if you proposal had a good solution to address this other part functionality, I would be accepting of a name change. I haven&#39;t ever been a fan of flatMap(_:) having 2 jobs, but it has been this way since Swift 1 or 2.</div></div></blockquote><div><br></div><div>`flatMap` is not going away or being renamed. One particular overload is being renamed so that the other overloads work as expected.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Also, I don&#39;t think the name `filterMap` makes sense with Swift naming conventions. To me it implies that you are going to map in place vs the filtered makes it clear you are creating a new Array to return. I really like the sort() vs sorted() naming convention that is already the standard for Swift code and would rather any name changes stick to that.<br></div></div></blockquote><div><br></div><div>`map`, `filter` and `flatMap` are settled exceptions to the Swift naming conventions because they are terms of art, and that&#39;s not changing going forward.</div><div><br></div></div><br></div></div>