![]() |
![]() |
![]() |
![]() |
![]() |
|
So that you can display Weight instances that have the same look as
those you type, you define a printOn: instance method for the
Weight class, thereby overriding the definition of the
printOn: instance method provided for the Object class.
Weight method definition instance printOn: aStream aStream nextPutAll: magnitude asString , 'gm'
Redefining the printOn: method changes the result produced by
printString because the printString method uses
printOn: to do the work of producing a string.