Ruby代码是:</p>
a = []
h = {}
2.times.each do |i|
%w(a b c).each do |x|
h[x] = x + i.to_s
end
a << h
end
结果是:
a = [{"c"=>"c1", "b"=>"b1", "a"=>"a1"}, {"c"=>"c1", "b"=>"b1", "a"=>"a1"}]
但我希望结果是:
a = [{"c"=>"c0", "b"=>"b0", "a"=>"a0"}, {"c"=>"c1", "b"=>"b1", "a"=>"a1"}]
谁能帮帮我.thx