Revisit
super
Dice class >> new
| inst |
inst := super new.
inst initialize.
^ inst
We execute the following expression: Dice new
Dice class >> new
| inst |
inst := super new.
inst initialize.
^ inst
inst
?super
?super new
?Dice class >> new
| inst |
inst := super new.
inst initialize.
^ inst
super
is not the superclassinst
is not an instance of the superclassDice class >> new
| inst |
inst := super new.
inst initialize.
^ inst
Dice new
Dice
Dice class >> new
| inst |
inst := super new.
inst initialize.
^ inst
super
is the receiver: the class Dice
new
in the superclass of the class Dice class
(Pay attention not Dice
)Dice
Dice
and send it initialize and return it
super
:)super
is the receiver of the message and the method lookup starts in the superclass of the class containing the expressionImagine we have
A >> foo
^ super class == self class
What is the result of A new foo
and why?
/