I want to know how whileTrue:
works. I searched the implementation that is in BlockClosure
:
whileTrue: aBlock
^ [self value] whileTrue: [aBlock value]
And another implementation with no parameter:
whileTrue
^ [self value] whileTrue: []
But I don't know how that works, that's a recursive method, but this led me to ask several questions:
- How does this recursive call terminate?
- If
[self value]
returns aBoolean
object, why iswhileTrue:
not implemented in theBoolean
type? - Why is there another implementation named
whileTrue
that just do not receive any block and evaluatesself
?