The Continue Statement

Another feature shortcoming of Lua is that it lacks the continue statement to jump back to the condition of the loop. This statement is essentially the opposite of the break statement and a feature that is found in most of today’s most popular programming languages. While the Lua creators have implemented a goto statement in more recent versions of Lua it is not as convenient as a continue.

while true do
   continue   -- Make an infinite loop
   print()    -- Never runs
end

Also, if continue is used in a repeat...until loop, it may not skip the local variable used in the loop condition. Code like this is invalid and will throw an error at compile time:

repeat
   continue     -- Compiler catches this!
   local a = 1
until a > 0

Last updated