This works in 1.9 at least.
If both arrays are the same size, you can use Array.zip and Hash[] like
this:
irb(main):001:0> alpha = (‘A’…‘Z’).to_a
=> [“A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”, “I”, “J”, “K”, “L”, “M”,
“N”, “O”, “P”, “Q”, “R”, “S”, “T”, “U”, “V”, “W”, “X”, “Y”, “Z”]
irb(main):002:0> ansi = %w{Alpha Bravo Charlie Delta Echo Foxtrot Golf
Hotel India Juliet Kilo Lima Mike November Oscar Papa Quebec Romeo
Sierra Tango Uniform Victor Whiskey X-ray Yankee Zulu}
=> [“Alpha”, “Bravo”, “Charlie”, “Delta”, “Echo”, “Foxtrot”, “Golf”,
“Hotel”, “India”, “Juliet”, “Kilo”, “Lima”, “Mike”, “November”,
“Oscar”, “Papa”, “Quebec”, “Romeo”, “Sierra”, “Tango”, “Uniform”,
“Victor”, “Whiskey”, “X-ray”, “Yankee”, “Zulu”]
irb(main):003:0> alpha.size
=> 26
irb(main):004:0> ansi.size
=> 26
irb(main):005:0> alpha.zip(ansi)
=> [[“A”, “Alpha”], [“B”, “Bravo”], [“C”, “Charlie”], [“D”, “Delta”],
[“E”, “Echo”], [“F”, “Foxtrot”], [“G”, “Golf”], [“H”, “Hotel”], [“I”,
“India”], [“J”, “Juliet”], [“K”, “Kilo”], [“L”, “Lima”], [“M”,
“Mike”], [“N”, “November”], [“O”, “Oscar”], [“P”, “Papa”], [“Q”,
“Quebec”], [“R”, “Romeo”], [“S”, “Sierra”], [“T”, “Tango”], [“U”,
“Uniform”], [“V”, “Victor”], [“W”, “Whiskey”], [“X”, “X-ray”], [“Y”,
“Yankee”], [“Z”, “Zulu”]]
irb(main):006:0> zippedhash = Hash[alpha.zip(ansi)]
=> {“A”=>“Alpha”, “B”=>“Bravo”, “C”=>“Charlie”, “D”=>“Delta”,
“E”=>“Echo”, “F”=>“Foxtrot”, “G”=>“Golf”, “H”=>“Hotel”, “I”=>“India”,
“J”=>“Juliet”, “K”=>“Kilo”, “L”=>“Lima”, “M”=>“Mike”, “N”=>“November”,
“O”=>“Oscar”, “P”=>“Papa”, “Q”=>“Quebec”, “R”=>“Romeo”, “S”=>“Sierra”,
“T”=>“Tango”, “U”=>“Uniform”, “V”=>“Victor”, “W”=>“Whiskey”,
“X”=>“X-ray”, “Y”=>“Yankee”, “Z”=>“Zulu”}
SUMMARY:
new_hash = Hash[array1.zip(array2)]
Quick-and-easy so long as array1 and array2 are equal length.
Aaron out.