Mark S. Miller (2015-04-15T20:20:05.000Z)
d at domenic.me (2015-04-19T23:53:14.984Z)
On Wed, Apr 15, 2015 at 1:11 PM, monolithed <monolithed at gmail.com> wrote: > I can not agree with this approach, [many languages](http://en.wikipedia.org/wiki/List_comprehension) have this functionality Which is why we were all surprised. > For example: > > ```js > var files = function (data) { > let result = []; > > for (let path of data) { > result.push(...fs.readdirSync(path)); > } > > return result; > } > ``` > > I believe that this code is awkward and not as beautiful as the possible > alternatives: > > > ```js > var files = function (data) { > return [ for (path of data) ...fs.readdirSync(path) ]; > } > ``` > > or > > ```js > var files = function (data) { > return data.map(path => ...fs.readdirSync(path)); > } > ``` > or, if we had flatMap ```js var files = function (data) { return data.flatMap(path => fs.readdirSync(path)); } ``` which looks as good as the comprehension and is clearer -- especially as a starting point for refactorings. So should we add flatMap? Yeah, probably.