# Re: A use case for an ordered hash

**URL:** <https://www.ruby-forum.com/t/re-a-use-case-for-an-ordered-hash/65995>\
**Category:** Ruby\
**Created:** [August 22, 2006, 8:11pm UTC](https://www.ruby-forum.com/t/re-a-use-case-for-an-ordered-hash/65995 "2006-08-22T20:11:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 22, 2006, 8:11pm UTC](https://www.ruby-forum.com/t/re-a-use-case-for-an-ordered-hash/65995/1 "2006-08-22T20:11:27Z")

</div>

That should have probably read:

m = [:a =\> ‘a’] # m is for map. I could go for this term too as it  
has brevity.  
=\> [:a =\> ‘a’]

m[0]  
=\> [:a =\> ‘a’] # m remains as an associative array.

m[:a]  
=\> ‘a’ # and m becomes an explicit hash.

m[0]  
=\> {:a =\> ‘a’} # m becomes an associative array.  
or  
=\> [:a =\> ‘a’] # conversion before or after?

m[:a]  
=\> ‘a’ # m becomes a hash again.

m[[0]]  
=\> ‘a’ # m becomes an associative array.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 23, 2006, 2:24am UTC](https://www.ruby-forum.com/t/re-a-use-case-for-an-ordered-hash/65995/2 "2006-08-23T02:24:17Z")

</div>

removed\_email\_address@domain.invalid wrote:

> =\> ‘a’ # and m becomes an explicit hash.  
> =\> ‘a’ # m becomes an associative array.  
> Again, interesting… but what if your keys are integers? Or arrays?

Hal
