# Merge with symbol problem

**URL:** <https://www.ruby-forum.com/t/merge-with-symbol-problem/75894>\
**Category:** Rails\
**Created:** [March 2, 2006, 9:14pm UTC](https://www.ruby-forum.com/t/merge-with-symbol-problem/75894 "2006-03-02T21:14:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abbath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@Abbath](https://www.ruby-forum.com/u/Abbath)\
**Post date:** [March 2, 2006, 9:14pm UTC](https://www.ruby-forum.com/t/merge-with-symbol-problem/75894/1 "2006-03-02T21:14:53Z")

</div>

Hi,

It’s a little bit annoying to me, I can’t understand the following:

If I merge a value to the params hash with:

params =\> params.merge :value =\> new\_value

the params[:value] doesn’t change, but if I use string instead of a  
symbol like:

params =\> params.merge “value” =\> new\_value

it works.

Somebody plz tell me why…

Abbath

---

<div class="post-metadata">

**Author:** ![Abbath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@Abbath](https://www.ruby-forum.com/u/Abbath)\
**Post date:** [March 2, 2006, 9:28pm UTC](https://www.ruby-forum.com/t/merge-with-symbol-problem/75894/2 "2006-03-02T21:28:30Z")

</div>

I believe that :value and “value” are complety different keys. One is  
a string, the other is a symbol.

---

<div class="post-metadata">

**Author:** ![Abbath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@Abbath](https://www.ruby-forum.com/u/Abbath)\
**Post date:** [March 7, 2006, 10:24pm UTC](https://www.ruby-forum.com/t/merge-with-symbol-problem/75894/3 "2006-03-07T22:24:50Z")

</div>

Ok, You would be right if the params object had been a Hash. But - as  
I know - it’s a HashWithIndifferentAccess object in which the symbol  
and the string key should be the same.

> I believe that :value and “value” are complety different keys. One is  
> a string, the other is a symbol.

---

<div class="post-metadata">

**Author:** ![Abbath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@Abbath](https://www.ruby-forum.com/u/Abbath)\
**Post date:** [March 24, 2006, 2:50am UTC](https://www.ruby-forum.com/t/merge-with-symbol-problem/75894/4 "2006-03-24T02:50:52Z")

</div>

A bit late to the party, but I filed a bug on this some while ago. It’s  
still in the queue, AFAIK.

In the mean while, you can work around it quite simply:

class HashWithIndifferentAccess  
def merge(hash)  
self.dup.update(hash)  
end  
end
