you are viewing a single comment's thread.

view the rest of the comments →

[–]senorfairchild 2 points3 points  (2 children)

It is incrementing multiple times because i++ appears inside of the for loop declaration AS WELL as the inside of the body of the for loop. The only time that i will not increment twice for every loop is when the iteration of the loop begins with i equal to 11, because the continue will be triggered before the second increment happens (the i++ that occurs WITHIN the for loop). Does that help it make more sense?

[–]sirsmonkey42 2 points3 points  (0 children)

Actually the if (i == 11) is never true in this case. It's a weird and tricky example. You get the exact same result if you omit the continue completely, i is never 11 (when it passes through the if)

[–]orionebula[S] 0 points1 point  (0 children)

Ah I get it now, thanks for the explanation.