I have an array of hashes like this:
[ {:foo=>2, :date=>Sat, 01 Sep 2014},
{:foo2=>2, :date=>Sat, 02 Sep 2014},
{:foo3=>3, :date=>Sat, 01 Sep 2014},
{:foo4=>4, :date=>Sat, 03 Sep 2014},
{:foo5=>5, :date=>Sat, 02 Sep 2014}]
And I want to combine hashes if they :datematch. What I expect from the array above:
[ {:foo=>2, :foo3=>3, :date=>Sat, 01 Sep 2014},
{:foo2=>2, :foo5=>5 :date=>Sat, 02 Sep 2014},
{:foo4=>4, :date=>Sat, 03 Sep 2014}]
How can i do this?
Perhaps I should review the data structure? For example, should a value be used dateas a hash key?
source
share