![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
The following method, for example, answers true
only if the
value of self
is between 1200 and 1600, inclusively:
Integer method definition instance inRange ^ (1200 <= self) & (self <= 1600) Workspace Transcript show: 1700 inRange printString; cr; show: 1400 inRange printString; cr; show: 1100 inRange printString. Transcript false true false
Similarly, the show:
message in the following method is sent only if
the value of self
is in the 1200-to-1600 range:
Integer method definition instance analyzeCalories (1200 <= self) & (self <= 1600) ifTrue: [Transcript show: self printString; show: ' is reasonable'; cr] Workspace 1700 analyzeCalories. 1400 analyzeCalories. 1100 analyzeCalories Transcript 1400 is reasonable