Greetings smalltalkers,
I'm a newbie trying to get my head around inheritance. I'm puzzled by the following example. It seems to do what I mean, but not what I type ;) This is a good thing, but I'd get further if I understood the semantics a bit better.
from http://www.cosc.canterbury.ac.nz/wolfgang.kreutzer/cosc205/smalltalk1.html
Class: Monster Superclass: Object Category: Sesame Street Instance variables: colour tummy
initialization
initialize self colour: #green. self tummy: Bag new
"There is only a single class method and no class variables."
creation
new ^ super new initialize
What I don't understand is this: Monster new returns an instance of Monster, what you'd want it to. But Monster new executes "^ super new" which to my mind should return an instance of Object, not Monster. Just to confuse myself further, I typed:
Monster superclass new
and got an Object. It seems to me that "super new" and "superclass new" should do the same thing.
Any points to clarify my confusion would be greatly appreciated.
Thanks, Dennis Petrocelli
--------------------------------- Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail.