Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我懂了:
first = [['lorem1','lorem1','lorem1',...],['lorem2','lorem2','lorem2',...],...] second = [value1,value2,value3, ...]
我想做这样的事情:
my_array_of_hash = [{value 1 =>lorem1, value2 => lorem1}, {value1 =>lorem2, value2 => lorem2}, .... ]
你能帮我吗?
hashes_array = [] first.each do |array| hashes_array << Hash[second.zip array] end
或者:
hashes_array = first.map do |array| Hash[second.zip array] end