![]() |
![]() |
![]() |
![]() |
![]() |
|
As explained in Segment 257, super is a signal to
initiate method search in the direct superclass of the class for which the
super-containing method is defined.
Suppose, for example, that new is sent to Vegetable. The
reference to super in the new method defined in
Segment 255 signals that search is to be initiated in the
Object class's metaclass, the direct superclass of the Food
class's metaclass, because the super-containing new method is
defined as a Food class method, which is an instance method of the
Food class's metaclass.
| Search starts here
| subclass |
v v
*--------------* instance *-------------------------------*
| Object class | <--------------- | Object class's metaclass |
*--------------* *-------------------------------*
| | new defined here
| subclass | subclass |
v v v
*--------------* instance *-------------------------------*
| Food class | <--------------- | Food class's metaclass |
*--------------* *-------------------------------*
| |
| subclass | subclass
v v
*-------------------* instance *-------------------------------*
| Vegetable class | <---------- | Vegetable class's metaclass |
*-------------------* *-------------------------------*
^
*-- new message sent here