a = {"rows" => [{"id" => "231-z", "name" => 'jon', "age"=> 27, "state" => 'AL'},
{"id" => "4121-x", "name" => 'ton', "age"=> 37, "state" => 'VA'}
]
}
b = {"rows" => [{"key" => ["xyz","4121-x"], "value" =>{"sum" => 12312, "realage" => 29}},
{"key" => ["xyz","231-z"], "value" =>{"sum" => 1212, "realage" => 33}}
]
}
在 hasha
中,age
不正确
在 hashb
中,realage
是正确的。在 hash id 中还有映射到hashb
的第一个数组中的第二个值。那些是 4121-x, 231-z 对应哈希 aid
a
我想更正哈希中的年龄a
并将其与哈希交换realage
我b
可以通过多个步骤来完成,但是是否可以在一个衬里或非常短的时间内完成?所以最后正确的哈希a
应该看起来像
a = {"rows" => [{"id" => "231-z", "name" => 'jon', "age"=> 33, "state" => 'AL'},
{"id" => "4121-x", "name" => 'ton', "age"=> 29, "state" => 'VA'}
]
}