Create a Matrix

I was trying to create an n by n zero matrix, by calling the class
Matrix: Matrix.zero(2).
I got the error message: uninitialized constant Matrix (NameError),
something I miss?

On 12/13/06, Christopher L. [email protected] wrote:

I was trying to create an n by n zero matrix, by calling the class
Matrix: Matrix.zero(2).
I got the error message: uninitialized constant Matrix (NameError),
something I miss?

You need to require the file - it’s in stdlib rather than core.

irb(main):001:0> Matrix.zero(2)
NameError: uninitialized constant Matrix
from (irb):1
irb(main):002:0> require ‘matrix’
=> true
irb(main):003:0> Matrix.zero(2)
=> Matrix[[0, 0], [0, 0]]

martin

thanks