July 2018
Beginner
202 pages
5h 42m
English
Syntactically, a while loop starts with the while keyword, followed by a Boolean condition and a do/end chunk. The loop will keep executing the chunk of code so long as the Boolean condition evaluates to true:
x = 10 -- Initialize a "control" variablewhile x > 0 do -- Boolean condition: x > 0 print ("hello, world") x = x - 1 -- Decrement the "control" variableend