From: Mark Woodward Date: 2007-01-04T08:00:07+09:00 Subject: Re: Array questions Hi Ken, Kenosis wrote: > All I can think of is this: the author of the maze code wanted to > ensure that the initial value of @paths was assured to be an empty > array. If he/she resorted to Array.new's default argument, which could > change then @path might not be in the state the programmer expected. > Other than that, as you surimised, the 3 ways you initialized the array > should all result in the same thing, AFAIK. > > Ken I suspected that but I couldn't understand how/why this could be done with a size 0. @paths = Array.new(0,Array.new(0)) to me reads as "create a new array with nothing in it and make that nothing reference another empty array?" ie [] @paths = Array.new(1,Array.new(0)) This, if my logic's right, reads as "create a new array with a single element that's an empty array. ie [[] ] Are you saying that even though @paths is created as an empty array, it expects the first element it gets to be an array? If not it will throw an error? Sorry, I can't check this in irb ATM. cheers, -- Mark