YouTip LogoYouTip

Lua Break Statement

# Lua break Statement [![Image 4: Lua Loops](#) Lua Loops](#) The Lua programming language `break` statement is inserted within a loop body to exit the current loop or statement and begin executing the next statement in the script. If you use nested loops, the `break` statement will stop the execution of the innermost loop and begin executing the statements of the outer loop. ### Syntax The syntax for the `break` statement in the Lua programming language is: break Flowchart: ![Image 5: Lua break Statement](#) ### Example The following example executes a `while` loop, printing the value of `a` as long as the variable `a` is less than 20, and terminates the loop when `a` is greater than 15: -- a = 10--while( a 15) then -- break endend The result of executing the above code is as follows: a's value is:10 a's value is:11 a's value is:12 a's value is:13 a's value is:14 a's value is:15 [![Image 6: Lua Loops](#) Lua Loops](#)
← Increment Decrement Operators Relational Operators Overloadi β†’