We’ve seen the break
in a switch
statement. It stops running the blocks of code, and simple exits out of the switch.
In the same manner, if you use a break
in a loop, it exits us from the loop prematurely (not by the loop condition).
The continue
keyword moves us to the end of the loop body and starts us over again. This means that the loop will continue, just not the rest of the loop body.
While these keywords can be very powerful, and make coding easier – if misused, which is often the case, it makes your code harder to read, debug, and maintain.
Therefore, I recommend steering clear of break
and continue
in anything but the switch statement.
Break and Continue was originally found on Access 2 Learn