![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Now for the recursion trick: you replace powerOfTwo
in
recursivePowerOfTwo
by recursivePowerOfTwo
itself.
Integer method definition instance recursivePowerOfTwo self = 0 ifTrue: [^ 1] ifFalse: [^ 2 * (self - 1) recursivePowerOfTwo] Workspace Transcript show: 4 recursivePowerOfTwo printString; cr Transcript 16