我有一个哈希数组
[ {:name => "bob", :type => "some", :product => "apples"},
{:name => "ted", :type => "other", :product => "apples"},....
{:name => "Will", :type => "none", :product => "oranges"} ]
我想知道是否有一种简单的方法来计算产品数量并将计数以及值存储在数组或哈希表中,内容如下:
我希望结果类似于:
@products = [{"apples" => 2, "oranges => 1", ...}]