In Ruby, I have an array of hashes and an array. In my array of hashes, I want to replace the values in one of the key-value pairs with the values from my second array. What is the cleanest way to accomplish this?
Example (I want to replace the value of “total” with the values from my second array):
Array of hashes:
[{"date":"2012-05-27","total":1},{"date":"2012-05-28","total":9}]
Array:
[1, 10]
Desired Array of hashes:
[{"date":"2012-05-27","total":1},{"date":"2012-05-28","total":10}]
1 Answer