In condition,
COLUMN = [:id, :tag_list, :price, :url, :Perweight, :Totalweight, :memo, :created_at, :updated_at]
row = {"id"=>4, "tag_list"=>"peanuts", "price"=>100, "Totalweight"=>390, "Perweight"=>nil, "url"=>nil, "memo"=>nil, nil=>nil}
from these two conditions, I want to make above Hash Object.
{:id=>4, :tag_list=>"peanuts", :price=>100, :Totalweight"=>390, :Perweight=>nil, :url=>nil, memo=>nil}
我试过,像这样...... 起初,我做空哈希,
new = Hash[COLUMN.zip([])]
p new
--->
{:id=>nil, :tag_list=>nil, :price=>nil, :url=>nil, :Perweight=>nil, :Totalweight=>nil, :memo=>nil, :created_at=>nil, :updated_at=>nil}
然后,我不知道该怎么做, 请给我建议吗?
答案 0 :(得分:4)