我想将以下哈希合并在一起。
h1 = {"201201" => {:received => 2}, "201202" => {:received => 4 }}
h2 = {"201201" => {:closed => 1}, "201202" => {:closed => 1 }}
特别是,我的预期结果是:
h1 = {"201201" => {:received => 2, :closed => 1}, "201202" => {:received => 4, :closed => 1 }}
我已经尝试了各种方法:
h = h1.merge(h2){|key, first, second| {first , second} }
不幸的是,对我来说,两者似乎都不是很好。任何建议将不胜感激。