3 ms·
2.7 introduces `Enumerable#filter_map` for that. Example from the NEWS file: [1, 2, 3].filter_map {|x| x.odd? ? x.to_s : nil } #=> ["1", "3"]
by Rafert 7y ago
2.7 introduces `Enumerable#filter_map` for that. Example from the NEWS file:
[1, 2, 3].filter_map {|x| x.odd? ? x.to_s : nil } #=> ["1", "3"]