Documentation
GitHubTwitter
  • overview
    • What is Lua++?
    • Why Lua++?
  • language improvements
    • Compound Assignments
    • Postfix and Prefix Operators
    • The Continue Statement
    • Constant Variables
    • Type Annotations
      • Function Annotations
    • Classes
      • Constructors
      • Templating
      • Inheritance
      • Encapsulation
    • Events
    • Macros
      • Lenient
      • Comment
      • C-Arrays
  • contributing
    • Installing the Project
Powered by GitBook
On this page

Was this helpful?

  1. language improvements

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
PreviousPostfix and Prefix OperatorsNextConstant Variables

Last updated 2 years ago

Was this helpful?