I have 2 hashes, for example:
{'a' => 30, 'b' => 14}
{'a' => 4, 'b' => 23, 'c' => 7}
where a
, b
and c
are objects. How can I sum those hashes' keys to get a new hash like:
{'a' => 34, 'b' => 37, 'c' => 7}
I have 2 hashes, for example:
{'a' => 30, 'b' => 14}
{'a' => 4, 'b' => 23, 'c' => 7}
where a
, b
and c
are objects. How can I sum those hashes' keys to get a new hash like:
{'a' => 34, 'b' => 37, 'c' => 7}
I some one looking to add more than 2 hashes, use this
In case of heterogeneous hash (containing both String and Number). For adding only integers.
Code is self explanatory.