Home Segments Index Top Previous Next

223: Mainline

You may also wish to use setters that seem to set derived attributes, but that actually set instance variables. For example, you can create a fGrams: setter, which seems to set the fGrams derived attribute, but which actually sets the fCalories instance variable:

Vegetable method definition • instance 
fGrams: aNumber 
  fCalories := aNumber * 9