July 2018
Beginner
202 pages
5h 42m
English
A repeat until loop is slightly different from a while loop. When using a while loop, the initial expression is evaluated first, so the following code would not execute the chunk of code belonging to the loop:
while false do print ("Not going to print")end
This happens because the Boolean condition of the loop is evaluated before the chunk of code is executed. A repeat until loop works the opposite way. The chunk of the repeat loop is executed first, then the condition is evaluated. This guarantees that a repeat until loop will execute its chunk at least once.
Syntactically, the repeat until loop begins with the repeat keyword, followed by the chunk of code to loop. The chunk ends with the until keyword, which is followed ...