Moderators IIYAMA Posted October 18, 2012 Moderators Share Posted October 18, 2012 What can you do with break? Does it works the same as return? (I can't find this on wikimta) Link to comment
Renkon Posted October 18, 2012 Share Posted October 18, 2012 It is like a return but for for and while Link to comment
Moderators IIYAMA Posted October 18, 2012 Author Moderators Share Posted October 18, 2012 I don't get what you mean: "for for and while" Link to comment
Anderl Posted October 18, 2012 Share 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. Link to comment
50p Posted October 18, 2012 Share 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 Link to comment
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