![]() |
![]() |
![]() |
![]() |
![]() |
|
Now, you can define the powerOfTwo method using a timesRepeat:
message instead of a whileTrue: or whileFalse: message:
Integer method definition instance powerOfTwo | result | result := 1. self timesRepeat: [result := result * 2]. ^ result Workspace Transcript show: 4 powerOfTwo printString Transcript 16