Continue / break
Let me show you how both continue and break work in loops.
Say we want to only go up to %result:
%result = 10 + 10;
for(%i=0;%i<100;%i++)
{
if(%i >= %result)
{
%gotResult = true;
break;
}
}
echo(%gotResult SPC %i);
OUTPUT:
==> "1 20"
So basically, once the for loop reached 20, we didn't need it to keep going, so we "broke" out of it, you see?
Say we want to only go up to %result:
%result = 10 + 10;
for(%i=0;%i<100;%i++)
{
if(%i >= %result)
{
%gotResult = true;
break;
}
}
echo(%gotResult SPC %i);
OUTPUT:
==> "1 20"
So basically, once the for loop reached 20, we didn't need it to keep going, so we "broke" out of it, you see?
Now for continue, say we want to skip %result:
%result = 1 + 1;
for(%i=0;%i<5;%i++)
{
if(%i == %result)
{
echo("let's continue back to the top!");
continue;
}
echo(%i);
}
OUTPUT:
==> "1"
==> "let's continue back to the top!"
==> "3"
==> "4"
==> "5"
That's basically it for continue and break. The same apply to while loops, breaks and continues work exactly the same in those loops too.
%result = 1 + 1;
for(%i=0;%i<5;%i++)
{
if(%i == %result)
{
echo("let's continue back to the top!");
continue;
}
echo(%i);
}
OUTPUT:
==> "1"
==> "let's continue back to the top!"
==> "3"
==> "4"
==> "5"
That's basically it for continue and break. The same apply to while loops, breaks and continues work exactly the same in those loops too.