# What is "!map:HashWithIndifferentAccess "?

**URL:** <https://www.ruby-forum.com/t/what-is-map-hashwithindifferentaccess/151781>\
**Category:** Rails\
**Created:** [October 25, 2008, 4:05pm UTC](https://www.ruby-forum.com/t/what-is-map-hashwithindifferentaccess/151781 "2008-10-25T16:05:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubyernewbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9dc877/32.png) [@rubyernewbie](https://www.ruby-forum.com/u/rubyernewbie)\
**Post date:** [October 25, 2008, 4:05pm UTC](https://www.ruby-forum.com/t/what-is-map-hashwithindifferentaccess/151781/1 "2008-10-25T16:05:19Z")

</div>

I read the typo migration code file 004\_add\_sidebars\_.rb and found  
these:

```
  Bare4Sidebar.create(:active_position=>0, :controller=>'page',

```

:active\_config=\>’— !map:HashWithIndifferentAccess  
maximum\_pages: “10”’)

I’m confused what does it meaning? work for?  
anyone help~

---

<div class="post-metadata">

**Author:** ![rubyernewbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9dc877/32.png) [@rubyernewbie](https://www.ruby-forum.com/u/rubyernewbie)\
**Post date:** [October 25, 2008, 4:26pm UTC](https://www.ruby-forum.com/t/what-is-map-hashwithindifferentaccess/151781/2 "2008-10-25T16:26:50Z")

</div>

On 25 Oct 2008, at 15:05, Zhenning G. wrote:

> I read the typo migration code file 004\_add\_sidebars\_.rb and found  
> these:
> 
> ```
> Bare4Sidebar.create(:active_position=>0, :controller=>'page',
> 
> ```
> 
> :active\_config=\>’— !map:HashWithIndifferentAccess  
> maximum\_pages: “10”’)
> 
> I’m confused what does it meaning? work for?

That looks like yaml serialized data.

Fred

---

<div class="post-metadata">

**Author:** ![rubyernewbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9dc877/32.png) [@rubyernewbie](https://www.ruby-forum.com/u/rubyernewbie)\
**Post date:** [October 25, 2008, 4:26pm UTC](https://www.ruby-forum.com/t/what-is-map-hashwithindifferentaccess/151781/3 "2008-10-25T16:26:50Z")

</div>

Guan,

HashWithIndifferentAccess is just like any other hash except that the  
key ‘somekey’ will be the same as the key :somekey.

For example if you have a regular hash like the following

> > hash = Hash.new({:somekey =\> ‘testing’})  
> > hash[:somekey]  
> > =\> testing  
> > hash[‘somekey’]  
> > =\> nil

Notice how the key ‘somekey’ is not the same as the key :somekey

> > hash = HashWithIndifferentAccess.new({:somekey =\> ‘testing’})  
> > hash[:somekey]  
> > =\> ‘testing’  
> > hash[‘somekey’]  
> > =\> ‘testing’

Here the key ‘somekey’ and :somekey are the same.

## Understand?

Robert Z.  
Zapient, LLC  
Ruby on Rails Development and Consulting

[http://www.zapient.com](http://www.zapient.com)

> **[From Java To Ruby](http://www.fromjavatoruby.com)**
>
> and everything in between...

On Oct 25, 7:05 am, Zhenning G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
