Answer the question
In order to leave comments, you need to log in
How to sum the values of multiple hashes in ruby?
there is an array of several hashes (the number varies)
example
arr = [{name: 'd1', value: 10}, {name: 'd2', value: 30}, {name: 'd1', value: 5}, {name: 'd3', value:4}, {name: 'd2', value: 5}]
How to get an array from it with the sum of the same names arr = [{name: 'd1', value: 15], {name: 'd2', value: 35}, {name: 'd3', value: 4}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question