0

If i have two arrays containing about 20 separate values is it possible to combine the two into a hash? With the contents of one array acting as the keys and the other as the values?

Tiago
  • 33
  • 3

1 Answers1

0

Sure, very simple

Hash[[1,2,3,4].zip([5,6,7,8])]
 => {1=>5, 2=>6, 3=>7, 4=>8} 

But it might be a problem if the arrays have not the same size.

Ursus
  • 29,643
  • 3
  • 33
  • 50