From: Clifford Heath Date: 2008-02-06T07:15:07+09:00 Subject: Re: creating a 2d array Adam Akhtar wrote: >> Todd's suggestion will work, but I prefer: >> rows, cols = 2,3 >> mat = Array.new(rows) { Array.new(cols) } >> >> Cameron > > Why do you use the {}? Arent they used when your creating hashes. This is a block (like do...end), not a Hash, in this context. The block is passed to the Array constructor and which calls it with each index to yield a value for the elements of the outer array being constructed. Clifford Heath.