Interesting. I almost never use reduce
or each_with_object
. Usually when I see people use these, what they really want is either something likethings.index_by(&:id)
, or Hash[values.map { |value| [value, foo(value)] }]
. reduce
is for the very special case where each subsequent value cares about the preceding state of the accumulator.