<div>Greetings smalltalkers,</div> <div> </div> <div>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.</div> <div> </div> <div>from <A href="http://www.cosc.canterbury.ac.nz/wolfgang.kreutzer/cosc205/smalltalk1.html">http://www.cosc.canterbury.ac.nz/wolfgang.kreutzer/cosc205/smalltalk1.html</A></div> <div> </div> <div>Class: Monster<BR>Superclass: Object<BR>Category: Sesame Street<BR>Instance variables: colour tummy</div> <div> </div> <div>initialization</div> <div> </div> <div>initialize<BR> self colour: #green.<BR>self tummy: Bag new</div> <div> </div> <div>"There is only a single class method and no class variables."</div> <div> </div> <div>creation<BR></div> <div>new<BR> ^ super new initialize</div>
<div> </div> <div>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:</div> <div> </div> <div>Monster superclass new </div> <div> </div> <div>and got an Object. It seems to me that "super new" and "superclass new" should do the same thing.</div> <div> </div> <div>Any points to clarify my confusion would be greatly appreciated.</div> <div> </div> <div>Thanks,<BR>Dennis Petrocelli<FONT color=#0000af> </FONT></div><p> 
                <hr size=1>Do you Yahoo!?<br> Everyone is raving about the <a href="http://us.rd.yahoo.com/evt=42297/*http://advision.webevents.yahoo.com/mailbeta"> all-new Yahoo! Mail.</a>