I would do it like this:
keys = ['BO','BR'] values = ['BOLIVIA','BRAZIL'] Hash[keys.zip(values)] # => {"BO"=>"BOLIVIA", "BR"=>"BRAZIL"}
If you need characters for keys, then:
Hash[keys.map(&:to_sym).zip(values)] # => {:BO=>"BOLIVIA", :BR=>"BRAZIL"}
In Ruby 2.1.0 or later, you can write them as:
keys.zip(values).to_h keys.map(&:to_sym).zip(values).to_h
source share