array =
[ {
:keyword => "A",
:total_value => "10"
},
{
:keyword => "B",
:total_value => "5"
},
{
:keyword => "C",
:total_value => "15"
},
{
:keyword => "B",
:total_value => "6"
},
{
:keyword => "A",
:total_value => "50"
},
{
:keyword => "D",
:total_value => "40"
},
{
:keyword => "A",
:total_value => "30"
}]
我正在尝试用相同的:keyword
值合并散列。通过巩固,我的意思是结合:total_value
。例如,合并后...
new_array =
[ {
:keyword => "A",
:total_value => "90"
},
{
:keyword => "B",
:total_value => "11"
},
{
:keyword => "C",
:total_value => "15"
},
{
:keyword => "D",
:total_value => "40"
}]