new to ruby: uninitialized constant

P

Paul Varoutsos

I have a program the simulates the knights tour problem. I made 2
classes, 1 called 'Location' which simulates a location on a chess board
and one called 'KnightsTour' which actually performs the knights tour.
Then I have a main.rb file which just creats a knights tour object
(KnightsTour.new) and calls a method on that object. But whenever i try
to run it, I get the following error:

C:\NetBeansWorkspace\KnightsTour\lib\main.rb:3:in `const_missing':
uninitialized constant KnightsTour (NameError)
from C:\NetBeansWorkspace\KnightsTour\lib\main.rb:8

Any help would be greatly appreciated.
 
J

Justin Collins

Paul said:
I have a program the simulates the knights tour problem. I made 2
classes, 1 called 'Location' which simulates a location on a chess board
and one called 'KnightsTour' which actually performs the knights tour.
Then I have a main.rb file which just creats a knights tour object
(KnightsTour.new) and calls a method on that object. But whenever i try
to run it, I get the following error:

C:\NetBeansWorkspace\KnightsTour\lib\main.rb:3:in `const_missing':
uninitialized constant KnightsTour (NameError)
from C:\NetBeansWorkspace\KnightsTour\lib\main.rb:8

Any help would be greatly appreciated.

Do you "require" the files containing the other two classes? Ruby will
not search for them automatically the way, for example, Java does.

-Justin
 
P

Paul Varoutsos

Justin said:
Do you "require" the files containing the other two classes? Ruby will
not search for them automatically the way, for example, Java does.

-Justin

Yes I did
 
J

Justin Collins

Paul said:
C:\NetBeansWorkspace\KnightsTour\lib\main.rb:3:in `const_missing':
uninitialized constant KnightsTour (NameError)
from C:\NetBeansWorkspace\KnightsTour\lib\main.rb:8


Yes I did


Then it is hard to tell what is going on without seeing your code. This
error generally means you either have not made the class available or
there is a typo somewhere, assuming KnightsTour is a class. Or possibly
you are using it before it is defined.

-Justin
 

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
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top