Is there a good way to map
and (select
or delete_if
) at the same time? At the moment, I do either of the following, but was wondering if there is a better way. Also, I cannot use the second one if I want a falsy value within the resulting array.
some_array.select{|x| some_condition(x)}.map{|x| modification(x)}
some_array.map{|x| modification(x) if some_condition(x)}.compact