I have just written the code for my first Ruby program, one that finds
the shortest path from start to finish in a maze. All i/o is through
files and a terminal. I have now turned to debugging it. To help me, I
have the books, “The Ruby P.ming Language” and “Ruby Cookbook”, and
of course vast internet resources. I’m using Ruby 1.8.7 on a MacBook. I
need a few answers to help me get started.
- Is this the normal way to debug a program: with a terminal window
open, save changes to the x.rb file in an editor, and enter
ruby “filename” args
in the terminal? (Presumable, using a Ruby IDE is another alternative.
I’ve also noted how irb works.) If “yes”, does the execution begin with
the first statement that is outside a class definition (as there seems
to be nothing comparable to C’s main(), for example)?
- Suppose I’ve defined two classes, C1 and C2, a “main” program and
some methods that are outside class definitions. Assume there is a
c1 = C1.new
in a class C2 method and
c2 = c2.new
in a method outside the two classes. In the file containing my code,
maze_problem.rb, do these blocks of code have to be placed in any
- I ran
in the terminal and got the following error message:
undefined method `=’ for nil:NilClass
with no reference to where in maze_problem.rb the problem occurred. How
do I go about finding the source of this error?