我想下面的哈希值合并到一起。
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} }
不幸的是,似乎迎刃而解了我。 任何意见将非常感激。