In your example .each.with_index
is redundant. I found this solution:
['a', 'b', 'c'].each_with_object({}).with_index do |(el, acc), index|
acc[index] = el
end
# => {0=>"a", 1=>"b", 2=>"c"}
In your example .each.with_index
is redundant. I found this solution:
['a', 'b', 'c'].each_with_object({}).with_index do |(el, acc), index|
acc[index] = el
end
# => {0=>"a", 1=>"b", 2=>"c"}