Home Segments Index Top Previous Next

104: Mainline

The fatToCalories method, as defined in Segment 89, contains only one expression, ^ self * 9. Most Smalltalk methods contain multiple expressions, divided into statements by periods. In the following definition of displayFatCalories, for example, there are three statements, each of which displays a string in the transcript:

Integer method definition • instance 
displayFatCalories 
  Transcript show: 'There are '. 
  Transcript show: (self * 9) printString. 
  Transcript show: ' calories in the fat' 
Workspace
194 displayFatCalories 
Transcript 
There are 1746 calories in the fat