Moderators IIYAMA Posted October 18, 2012 Moderators Posted October 18, 2012 What can you do with break? Does it works the same as return? (I can't find this on wikimta)
Moderators IIYAMA Posted October 18, 2012 Author Moderators Posted October 18, 2012 I don't get what you mean: "for for and while"
Anderl Posted October 18, 2012 Posted October 18, 2012 break stops for loops, while statements and I guess it stops repeat too. It's a common "variable" in almost all languages.
50p Posted October 18, 2012 Posted October 18, 2012 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now