Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to determine when for-loop is done
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#7
RE: How to determine when for-loop is done

Although these might not exactly answer your question individually, they're useful to know. I haven't tested them all in AngelScript, but I assume they work.

In Java, there's a keyword called "continue" which will skip the remaining code within a loop, but then continue the loop after. So for example you could do:

PHP Code: (Select All)
for(int i 1<= 5i++) {
    if(
== 3) continue;
    Print(
"Step " i);
}
Print(
"End"); 

It produces:

Step 1
Step 2
Step 4
Step 5
End

There's another keyword called "break" which is similar, but it also stops the remaining iterations of the loop. Let's use the above example, but have "break" instead of "continue." It will produce this:

Step 1
Step 2
End

You already know of "return" so I won't go there. But just for reference, using it would kill the "End" as well.

Another keyword is "goto" but it should not be used, at least in Java. Perhaps it's usable in C.

(This post was last modified: 06-16-2015, 01:54 PM by Mudbill.)
06-16-2015, 01:45 PM
Find


Messages In This Thread
RE: How to determine when for-loop is done - by Mudbill - 06-16-2015, 01:45 PM



Users browsing this thread: 1 Guest(s)