ちょっと私は次のようなハッシュ値の配列を持っています。
[{"group" => "1", "message" => "hey", "weight" => 1}, {"group" => "1", "message"
=> "hey1", "weight" => 2}, {"group" => "2", "message" => "hey3", "weight" => 4}]
group_by グループ化し、次のようにフォーマットします。
[{"group" => 1, "messages" => {"hey","hey1"}, "weights" => {1,2}}, {"group" => 2,
"messages" => {"hey3"}, "weights" => {4}}]
これを達成するための素敵なルビーの方法はありますか?
編集:今私は持っています:
[
{"group" => "1", "message" => {"hey" => "1"}},
{"group" => "1", "message" => {"hey1" => "2"}}
]
私はしたいです
{"group" => "1", "messages" => {"hey1" => "1", "hey2" => "2"} }