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 aBooleanobject, why iswhileTrue:not implemented in theBooleantype? - Why is there another implementation named
whileTruethat just do not receive any block and evaluatesself?