# Conditionally adding hash values in one array

**URL:** <https://www.ruby-forum.com/t/conditionally-adding-hash-values-in-one-array/145021>\
**Category:** Rails\
**Created:** [August 5, 2008, 10:49am UTC](https://www.ruby-forum.com/t/conditionally-adding-hash-values-in-one-array/145021 "2008-08-05T10:49:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![russel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee7513/32.png) [@russel](https://www.ruby-forum.com/u/russel)\
**Post date:** [August 5, 2008, 10:49am UTC](https://www.ruby-forum.com/t/conditionally-adding-hash-values-in-one-array/145021/1 "2008-08-05T10: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.
