Sign in to follow this  
Followers 0
atrX

Scripting Basics: Break, Continue and Return

1 post in this topic

Break

Break is used to exit the current statement, you'll see this often used in loops and switch statements. Here's an example:

Please login or register to see this code.

As soon as stopLoop is set to true the loop will stop and the function will start executing the code after the loop.

 

Continue

Continue is used to exit the current instance of a loop, let's have a look at an example:

Please login or register to see this code.

If doContinue is true, the current instance of this infinite loop will end and it'll start a new one from the top.

 

Return

Return is used to exit the current function and optionally return a value.

Please login or register to see this code.

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0