From: Paet Worlds II Date: 2012-01-23T02:24:30+09:00 Subject: Re: Why do I receive this error? Dave Aronson wrote in post #1042042: > 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 Well.. I tried that and received: C:\Users\PandE\Desktop\RoboSteve\RoboEngine.rb:5:in `initialize': undefined local variable or method `init' for # (NameError) from C:\Users\PandE\Desktop\RoboSteve\RoboEngine.rb:58:in `new' from C:\Users\PandE\Desktop\RoboSteve\RoboEngine.rb:58 I mean... I don't even know what "#<0x2f7f2faa> means... -- Posted via http://www.ruby-forum.com/.