From: "David A. Black" Date: 2005-10-12T08:13:11+09:00 Subject: Re: multi-dimensional Arrays Hi -- On Wed, 12 Oct 2005, Peter v. N. wrote: > Thank you for all the replies! This is really great. > > But I still wonder (or play dumb here): > > what's the difference between > > arr = Array.new(3) { Array.new(3) } > > and > > arr = Array.new(3, Array.new(3)) In the first one, the block is executed once each time to fill up the array. It's like: arr = [Array.new(3),Array.new(3),Array.new(3)] So it's an array of three different arrays. The second one sets all three initial values to the *same* array. It's like: inner = Array.new(3) arr = [inner,inner,inner] So you've got an array of three copies of the same object, which of course has major implications when you modify that object, etc. David -- David A. Black dblack@wobblini.net