У меня есть массив хэширования в Ruby, который выглядит так:
domains = [
{ "country" => "Germany"},
{"country" => "United Kingdom"},
{"country" => "Hungary"},
{"country" => "United States"},
{"country" => "France"},
{"country" => "Germany"},
{"country" => "Slovakia"},
{"country" => "Hungary"},
{"country" => "United States"},
{"country" => "Norway"},
{"country" => "Germany"},
{"country" => "United Kingdom"},
{"country" => "Hungary"},
{"country" => "United States"},
{"country" => "Norway"}
]
Из этого массива хэшей я хочу создать новый хеш, выглядит примерно так:
counted = {
"Germany" => "3",
"United Kingdom" => "United Kingdom",
"Hungary" => "3",
"United States" => "4",
"France" => "1"
}
Есть ли простой способ сделать это с помощью Ruby 1.9?