[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: A use case for an ordered hash

thoran@thoran.com

8/22/2006 6:11:00 PM

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.


1 Answer

Hal E. Fulton

8/23/2006 12:23:00 AM

0

thoran@thoran.com wrote:
> 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.


Again, interesting... but what if your keys are integers? Or arrays?


Hal