From: Todd Benson Date: 2007-10-20T06:36:24+09:00 Subject: Re: 2 dimensional array On 10/19/07, Victor Reyes wrote: > Sorry guys, I am very slow. > In conclusion. how would the following be represented in Ruby? > It is a 3x3 matrix. > > 11 76 -34 31 -66 71 -1 63 34 > Thank you It depends on what you want to do. If you just want to represent it as a nested array, you could... my_matrix = [[11, 76, -34], [31, -66, 71], [-1 63 34]] As you notice, this is still 2-dimensional. For math type matrix functionality, there is the matrix standard library... require 'matrix' which includes methods that return a manipulated matrix (represented by the Matrix object), like inverse, rank, determinant, algebraic functions, etc. I believe you can also go back and forth between nested arrays and Matrix objects using Matrix#to_a and Matrix#[](*rows). Somebody else might be able to fill you in better. You can find documentation for that under the standard library docs at http://www.ruby-doc.org. hth, Todd