From: Robert Dober Date: 2007-01-04T00:09:32+09:00 Subject: Re: Array questions ------=_Part_144214_30688057.1167836969008 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 1/3/07, Mark Woodward wrote: > > Hi, > > Aren't these equivalent? Yes they are! I guess that the author wanted to demonstrate what kind of objects will be stored in the Array later, but it is not very readable and concise, looking at the code he might have written something like this Array.new(0){ Array.new(2){ 0 } } which still is [] of course but which might be interpreted as an empty Array that should only have arrays of two distinct objects that are integers. I guess this style might not be everyone's cup of tea, I personally would like the "auto-documentation" idea which might be the origin of the code but not quite successfully I guess :( Please note to almost always use the block form as arry=Array.new(n,'a') creates n times the same reference to "a" and arry.last.sub!("a","b") changes arry into ["b", "b",..., "b"] HTH Robert i > > -- > Mark > > -- "The real romance is out ahead and yet to come. The computer revolution hasn't started yet. Don't be misled by the enormous flow of money into bad defacto standards for unsophisticated buyers using poor adaptations of incomplete ideas." - Alan Kay ------=_Part_144214_30688057.1167836969008--