From: Dave Aronson Date: 2012-01-23T01:59:19+09:00 Subject: Re: Why do I receive this error? On Sun, Jan 22, 2012 at 11:42, Paet Worlds II wrote: > And here is the error I get: > > C:\Users\Paetilium\Desktop\RoboSteve\RoboEngine.rb:5:in `initialize': > 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 Initialization#action1. 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? -Dave -- Dave Aronson, President, Dave Aronson Software Engineering and Training Ruby on Rails Freelancing (Northern Virginia, Washington DC, or Remote) DaveAronson.com, Codosaur.us, Dare2XL.com, & RecruitingRants.com (NEW!) Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (me)