Home Segments Index Top Previous Next

251: Mainline

Suppose that you want to announce the creation of every Food instance. You could define an instance method for, say, the Food class, so as to make the required announcement. The method is, of course, inherited by the Vegetable class:

Food method definition • instance 
announce 
  Transcript show: 'Creating a new class instance: ' 
                   , self printString; cr. 
Workspace
Vegetable new announce 
Transcript 
Creating a new class instance: a Vegetable