So is there a way to jump out of a loop that is being executed instantly after the condition isn't met anymore? Because a while loop is executing 'till the end of the loop, even if the condition isn't met anymore, right?
For example:
normal while loop:
what i want:
I know that I could do this by putting every instruction into a if loop, but thats pretty confusing and its getting the method pretty big if I got a lot of instructions. Is there a easier way to do it?
while(condition())
{
instruction1;
instruction2;
instruction3;
instruction4;
instruction5;
}
while(condition())
{
instruction1();
checkcondition(); //if condition is met, go on, if it isn't break out of the loop
instruction2();
checkcondition();
instruction3();
checkcondition();
instruction4();
checkcondition();
instruction5();
}
