[Newbies] Laser game tutorial again

Benjamin Schroeder benschroeder at acm.org
Sat Jul 21 13:01:54 UTC 2007

On Jul 21, 2007, at 8:25 AM, gruntfuttuck wrote:

> I'm getting three errors with the Test Runner. It would seem that a
> BlankCell object doesn't  understand the message exitSides:
> Or do I actually. It looks like it should be:
> initializeExitSides
> 	self exitSides := Dictionary new.
> not
> initializeExitSides
> 	self exitSides: Dictionary new.
> Is this another way to do assignment? Anyway it's not working and  
> that's how
> the tutorial says to do it.
> I'm really curious to what the problem is. Can anyone enlighten me?

The exitSides: message looks like an accessor, a method for setting  
the value of an instance variable. That method would be implemented  
much like the assignment you give above:

	exitSides: aDictionary

		exitSides := aDictionary

The preceding "self" isn't used when referring to the name of an  
instance variable.

Accessors let other objects set the values of variables directly, and  
are sometimes thought to be more helpful for possible later changes.  
Sometimes they do things like alerting other objects of changes. When  
there's no behavior above and beyond simple setting, from inside the  
same object, their use is largely a matter of personal style.

I haven't read through the whole tutorial, but perhaps the exitSides:  
method is defined elsewhere. In any case, I'd guess that you are  
correct and it is trying to do an assignment, although it may also  
need to do other things.

Hope this helps,
Benjamin Schroeder

More information about the Beginners mailing list