[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Create a Matrix

Christopher Latif

12/13/2006 11:55:00 AM

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?

--
Posted via http://www.ruby-....

1 Answer

Martin DeMello

12/13/2006 11:59:00 AM

0

On 12/13/06, Christopher Latif <christopherl@bredband.net> 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