Jump to content

"Break"


IIYAMA

Recommended Posts

  • Moderators
Posted

What can you do with break?

Does it works the same as return?

(I can't find this on wikimta)

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

  • Moderators
Posted

I don't get what you mean: "for for and while"

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

break stops for loops, while statements and I guess it stops repeat too.

It's a common "variable" in almost all languages.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

return stops the function and returns a value or multiple values,

break, breaks the loop but doesn't stop a function

function aFunc( stopAt ) 
    local a; 
    for i = 1, 10 do 
        if i == stopAt then 
            a = i; 
            break; -- stops the loop but keeps executing rest of the function 
        end 
    end -- break hits end of the loop 
    -- do something else here 
    return a; 
end 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...