This blog is part of our Ruby 2.7 series.
Ruby 2.7.0 was released on Dec 25, 2019.
Ruby 2.7 adds Enumerable#filter_map
which is a combination of filter + map as the name indicates. The ‘filter_map’
method filters and map the enumerable elements within a single iteration.
Before Ruby 2.7,
we could have achieved the same with 2 iterations
map combination or
Ruby 2.7 adds
which can be used to filter & map the elements in
a single iteration and which is more faster when compared to
other options described above.
The original discussion had started 8 years back.
Here is the latest thread and