我明白了:
first = [['lorem1','lorem1','lorem1',...],['lorem2','lorem2','lorem2',...],...]
second = [value1,value2,value3, ...]
我想做那样的事情:
my_array_of_hash = [{value 1 =>lorem1, value2 => lorem1}, {value1 =>lorem2, value2 => lorem2}, .... ]
你可以帮帮我吗?
答案 0 :(得分:3)
hashes_array = []
first.each do |array|
hashes_array << Hash[second.zip array]
end
或:
hashes_array = first.map do |array|
Hash[second.zip array]
end