On Sun, Jan 22, 2012 at 11:42, Paet Worlds II [email protected]
And here is the error I get:
uninitialized constant RoboEngine::Init (NameError)
What the error message is saying is that within the context of
RoboEngine::initialize, it has no clue what Init is, and the first
letter is uppercase so it’s taking it as a constant. There are (at
least) two ways you can fix this.
The horrible ugly klugy way that should make everyone want to rinse
their eyeballs in bleach for having read it, is to make Init a global
variable. This is So Wrong that I’m not going to tell you how, though
you could easily Google it.
The cleaner way would be to make Init, within RoboEngine#initialize, a
parameter. (Of course, you’d then lowercase the name, at least the
first letter, so it’s no longer a constant.) That has many
advantages. Mainly, you will certainly know what it is, because it’s
been passed in. Also, the caller won’t have to have set up something
specifically called Init, it can call it whatever it wants, and even
have several of them to choose from at call time.
Note that you’ll have the same problem with ThoughtP in
Any time you have Ruby complaining about not knowing what something
is, like method missing, uninitialized constant, etc., ask yourself:
how is it supposed to know, and is that good clean engineering or a
horrible quick and dirty kluge, in which case what would be better?