Introduction to OOP Chapter 16: Overriding : next previous audio real text

Overriding a Default Method

We saw one example of overriding a default method in the solitare game. Here is another from Smalltalk. Class Number has child classes Integer, Fraction and Float. Method in class Number is defined as follows:
"class Number"
		^ self asFloat sqrt
The method in class Float clearly must perform something different, in this case actually computing the square root. The parent class has a method that will work in most, but not all, child classes.
Intro OOP, Chapter 16, Slide 09