Loop Controls
Learn about different loop controls in Solidity.
We'll cover the following
Solidity gives us complete control over loop statements. There might be times when we need to exit a loop without reaching its bottom. We might also wish to skip a section of our code block and begin the following iteration of the loop. Solidity includes the break
and continue
statements to handle all of these scenarios. These statements are used to exit any loop instantly or to begin the next iteration of any loop.
The break
statement
The break
statement is used to leave a loop early by breaking out of the curly braces that surround it. The syntax for this is as follows:
Get hands-on with 1400+ tech skills courses.