[Block] whileTrue: [block] | Manual

[Block] whileTrue: [block]

Runs a block of code, depending on the outcome runs the other block as long as the result of the first one equals boolean True.

 x := 0.
 { ^(x < 6). } whileFalse:
 { x add: 1. }. #increment x until it reaches 6.

 Here we increment variable x by one until it reaches 6.
 While the number x is lower than 6 we keep incrementing it.
 Don't forget to use the return ^ symbol in the first block.

back to homepage
back to manual menu

This API reference guide has been generated automatically from source code comments using the shtml.ctr script.