On Mon, Nov 8, 2010 at 7:00 AM, Misha Ognev <b1368810 / lhsdv.com> wrote: > Hello, this don't work on ruby 1.9.2. What's matter? Arrays in ruby are dynamic in so far as to its size. > $a = Array.new > for i in 1..5 $a[i] = [] # insert; here we specify that the ith element is an array > ¨Âïò éî ±®®¸ > a[i][j] = i*j > ¨Âîä > end $a #=> [nil, [nil, 1, 2, 3, 4, 5, 6, 7, 8], [nil, 2, 4, 6, 8, 10, 12, 14, 16], [nil, 3, 6, 9, 12, 15, 18, 21, 24], [nil, 4, 8, 12, 16, 20, 24, 28, 32], [nil, 5, 10, 15, 20, 25, 30, 35, 40]] note you have nils in there since arrays in ruby start at 0 index. nonetheless, that was the long way. now pls try playing w Array.new especially the block form. eg, Array.new(6){|i| 9.times.map{|j| i*j} } #=> [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 2, 4, 6, 8, 10, 12, 14, 16], [0, 3, 6, 9, 12, 15, 18, 21, 24], [0, 4, 8, 12, 16, 20, 24, 28, 32], [0, 5, 10, 15, 20, 25, 30, 35, 40]] note, no nils. hth. kind regards -botp