Greetings!
I'm having a little problem with n-dimensional arrays. Here's what I intend to do:

  I want to create 2-dimensional array which I'm using as a grid for a simulation. The initialize method receives (among others) two values, one for the number of rows and one for the number of colums, which I store in @rows and @cols respectively. The intialize method also creates the lattice based on those values with the following code

  @lattice = Array.new(@rows, Array.new(@cols))
  k = 0
  for i in 0...@rows
     for j in 0...@cols
        @lattice[i[j]] = k % 10
        k = k + 1
     end
  end

I only use k for testing purposes - I expected to see a sequence of numbers from 0 to 9 repeating across the grid when I use

  for i in 0...@rows
     for j in 0...@cols
        print @lattice[i[j]].to_s << " "
     end
     print "\n"
  end

However, my results are far from that - I get something similar to this:

0 0 0 0 0 0 0
5 0 0 0 0 0 0
0 5 0 0 0 0 0
5 5 0 0 0 0 0
0 0 5 0 0 0 0
5 0 5 0 0 0 0
etc... 

basically inverted binary number representations (the 5 and 0 are constant if I use mod 10... when I use mod 11 I get 6 and 8 instead). Could anyone help me out here? Where am I erring?

-- 
CWStrommer - New equipment FuBARing daily!


__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp 

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/