# conditionally adding hash values in one array

**URL:** <https://discuss.rubyonrails.org/t/conditionally-adding-hash-values-in-one-array/32815>\
**Category:** rubyonrails-talk\
**Created:** [August 5, 2008, 8:49am UTC](https://discuss.rubyonrails.org/t/conditionally-adding-hash-values-in-one-array/32815 "2008-08-05T08:49:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [August 5, 2008, 8:49am UTC](https://discuss.rubyonrails.org/t/conditionally-adding-hash-values-in-one-array/32815/1 "2008-08-05T08:49:36Z")

</div>

Hi there,

Can anyone help me with this. I'm still new to ruby on rails and I'm really stuck on it.

I have an array containing hashes.

e.g.

a =\> [{:key1=\>value, key2=\>value,key3=\>value},{:key1=\>value, key2=\>value,key3=\>value},{:key1=\>value, key2=\>value,key3=\>value}]

Want I want to do is add the the value of key3 if their key1 and key2 are equal and save it to another array.

Is there a ruby-like way to do this?

Thanks for any help.
