Convert an array to hash, where keys are the indices
arr = ["one", "two", "three", "four", "five"]
x = Hash[(0...arr.size).zip arr]
# => {0=>"one", 1=>"two", 2=>"three", 3=>"four", 4=>"five"}
x = Hash.new{|h, k| h[k] = arr[k]}
Ruby < 2.1:
Hash[arr.map.with_index { |x, i| [i, x] }]
#=> {0=>"one", 1=>"two", 2=>"three", 3=>"four", 4=>"five"}
Ruby >= 2.1:
arr.map.with_index { |x, i| [i, x] }.to_h