array.each_with_index.to_h
each_with_index gives you [element, index] pairs.
each_with_index
[element, index]
to_h converts an array of pairs ([key, value]) into a H
to_h
[key, value]