Closed bga closed 6 years ago
in Ruby there are Array#flatten(deep = +Infinity)
and Array#flat_map(mapper)
(always infinite deep coz how to deal with array leafs - transform via mapper or leave as is or may be go deeper and map but leave nested structure)
The mapper argument is certainly used in the wild; what is this issue about, exactly?
i assume Array#flatten(deep = +Infinity, mapper = null, thisArg =null)
would be optimal to avoid 2nd map(mapper)
chain call
I have no idea what is going on in this thread.
@bga “flatten” and “flatMap” have been intentionally chosen for this proposal with their current APIs. An API with an optional callback and an optional thisArg is unlikely to fly, and has no precedent I’m aware of in the language.
Why did you file this issue?
Ok. I dont know what is current API you talking about (lodash?). Just remove anything related mapper
to avoid questions from other ppl.
flatMap
takes a mapper function callback, and will continue to do so. flatten
does not (it only takes a depth
).
do you want to clone https://apidock.com/ruby/Enumerable/flat_map ?