Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Starting from an array of sub-arrays, each sub-array is a 2 elements key|value pair. Example
- input = [[:A, 5], [:B, 2], [:A, 12], [:B, -2], [:C, 7]]
- Convert this into a hash that has distinct keys from above, with values summed up, so the above would be:
- output = {:C 7, :B 0, :A 17}
Add Comment
Please, Sign In to add comment