jeudi 7 avril 2016

Insert in multiple arrays, in hash with key values in ruby

array1 = [[a,b,c],[1,2,3],[x,y,z]]
array2 = [[1,2,1],[2,2,2],[a,a,a]]
array3 = [[d,d,d], {a=>1,b=>2}]

@keys = key1,key2,key3  

i need to to show the one single hash in below format

  output = {"key1" => [[a,b,c],[1,2,3],[x,y,z]], "key2" => [[1,2,1],[2,2,2],[a,a,a]], "key3" => [[d,d,d], {a=>1,b=>2}] }

i am tried to in this code

    Hash[@key.zip(array1)]

Aucun commentaire:

Enregistrer un commentaire