On Thu, 20 Nov 2003 03:43:24 +0900, Charles Hixson wrote:
> Austin Ziegler wrote:
>> hash_maker = proc { |h, k| h[k] = Hash.new(&hash_maker) }
>> msa = Hash.new(&hash_maker)
>> 
>> http://www.rubygarden.org/ruby?HashOfHashes

> How would you index along other than the first dimension? But
> that's one of the main requirements.

Using the above:

    hash_maker = proc { |h, k| h[k] = Hash.new(&hash_maker) }
    msa = Hash.new(&hash_maker)
    msa[0]            # => {}
    msa[0][5]         # => {}
    msa               # => {0=>{5=>{}}
    msa[5][3][2] = 3  # => 3
    msa               # => {5=>{3=>{2=>3}}, 0=>{5=>{}}}

The first pitfall that you'll have is:

    msa[0] = 3
    msa               # => {5=>{3=>{2=>3}}, 0=>3}

The second pitfall is on the HashOfHashes page.

-austin
--
austin ziegler    * austin / halostatue.ca * Toronto, ON, Canada
software designer * pragmatic programmer * 2003.11.19
                                         * 15.36.49