The break statement

Loops help iterateing over from the start till it arives on a vector data type. However, there are times when you would like to stop the iteration in between and jump out or exit from the loop without executing the conditional test again. The break statement helps us do that. It helps us terminate the loop by passing the control to the first instruction after the loop.

In the following screenshot example, the for loop is terminated and control moves out of the for loop when the value of i is 1 because of the use of the break statement. It literally breaks the loop as shown in the following screenshot:

Get Solidity Programming Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.