From: Bill Kelly Date: 2005-08-17T15:02:38+09:00 Subject: Re: Ruby 2 Idea: You've got to have a[a][b][c][d][e][f][g][h][i]... From: "Xeno Campanoli" > > There are just too many problems that can quickly be solved by > multi-dimensional arrays and hashes not to have them and have them > easily. I used the hack from "matz" today to make a 2d hash, and it's > ugly and unworthy of Ruby. You should be able to do this without any > extra steps just like in Perl. If the project ends up getting bigger > THEN you refactor it, but YOU JUST GOT TO HAVE THAT. I don't know how to do it with Array, because Array doesn't seem to accept a block for its default value generation like Hash does. But with Hash: hoh = lambda { Hash.new {|h,k| h[k] = hoh.call} } >> x = hoh.call # create autovivifying hash-of-hashes => {} >> x[1][2][3][4][5] = "spleen" => "spleen" >> x => {1=>{2=>{3=>{4=>{5=>"spleen"}}}}} Regards, Bill