I have problem many time understanding the errors i get in the squeak program, and unable to fix and debug it. like in this case:
I wrote the following code is smalltalk language in squeak:
initilize
super initialize.
path := OrderedCollection new.
-
drawOn: aCanvas
| colors |
colors := Color wheel: 10.
colors withIndexDo:[:c :i |
aCanvas fillOval: (self bounds insetBy: self width/25*i+1 )
color: c
].
-
handlesMouseDown: evt
^true.
-
mouseDown: evt
self position: self position + (10@0).
-
startAnimation
path reset.
0 to: 9 do: [:i | path add: self position +(0@(10*i))].
path := path, path reverse.
self startStepping.
-
step
path size > 0 ifTrue: [self position: path removeFirst].
and this is the code I wrote in the workspace:
myMorph := TestMorph new openInWorld.
but I am getting and error that I wrote up, something about problem with "size" in "step" method can someone see the problem?
When you get an error message about UndefinedObject
it often means that some variable was not initialized correctly, it has the value nil
.
The error is that you misspelled initialize
You wrote initilize
instead. This method is not called when creating your object and thus the path
instance variable is let undefined (nil).