Create a Matrix

C

Christopher Latif

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?
 
M

Martin DeMello

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top