flat_map
to flatten maps RB-PR1011flat_map
is more efficient than flatten
. Refer here.
[1, 2, 3, 4].map { |e| [e, e] }.flatten(1)
[1, 2, 3, 4].flat_map { |e| [e, e] }
By default, flatten
without any arguments do not raise any issues. Set EnabledForFlattenWithoutParams
to true
in your .rubocop.yml
to enable it.