From: Shawn W_ Date: 2009-09-12T13:06:32+09:00 Subject: Re: Nooby question : multidimensional arrays. 01 class Array2D 02 03 def initialize(width, height) 04 @data = Array.new(width) { Array.new(height) } 05 end 06 07 def [](x, y) 08 @data[x][y] 09 end 10 11 def []=(x, y, value) 12 @data[x][y] = value 13 end 14 15 end Can someone explain what's going on in this code for a newbie. I'm getting lost in the looping logic of the second def; and the 3rd def I'm guessing has something do do with hashes? I'm using this code in a simple 2d array. It was working but then I changed all of my ranges from (0...value) to (1..value) [I used ranges to populate my 2D array with hashes] I now get the error message: 11:in `[]=': undefined method `[]=' for nil:NilClass (NoMethodError) -- Posted via http://www.ruby-forum.com/.