> For the complete documentation index, see [llms.txt](https://muradkarakas.gitbook.io/sodium_documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://muradkarakas.gitbook.io/sodium_documentation/language-reference/lexical-elements/statements/the-break-statement.md).

# The break Statement

You can use the break statement to terminate a while, do or switch statement. Here is an example:

```
int x = 1;
while (x < 1000) loop
    if (x == 8) then
      break;
    else
      message(x);
    end if;
    x = x  + 1;
end loop;
```

That example prints numbers from 1 to 7. When x is incremented to 8, x == 8 is true, so the break statement is executed, terminating the for loop prematurely.

If you put a break statement inside of a loop or switch statement which itself is inside of a loop or switch statement, the break only terminates the innermost loop or switch statement.
