Ruby array to an indexed hash?
I think the most idiomatic way from Ruby 2.1 onwards is to use .to_h
since it can be called on a block like so:
(65..90).map { |i| [i, i.chr] }.to_h
What about
Hash[(65..90).map { |i| [i, i.chr] }]
I think this is quite obvious and self-explaining. Also, I don't there exists a much simpler way to solve this rather specific task, Ruby unfortunately doesn't have something comparable to dict comprehension in Python. If you want, you can use the Facets gem, which includes something close:
require 'facets'
(65..90).mash { |i| [i, i.chr] }