# break statement

Source: https://ref.dm-lang.org/proc/break

### Format
- `break`
- `break Label`


Terminate the loop with the given label. If no label is specified, the innermost loop containing the `break` statement is assumed.

```dm
obj/zapper
  verb/use()
    var/mob/M

    for(M in view())
      if(!M.key) break

    if(!M) M = usr
    M << "ZAP!"
    del(M)
```

The zapper object kills the first mob it finds that doesn't belong to a player. If none can be found, it kills the user. Be careful! Note how this code takes advantage of the fact that the loop variable M will be `null` if the loop terminates normally.

For an example of how to use labeled loops, see the reference section for the `continue` statement.

The `break` statement can also be used inside of a [`switch()` proc](https://ref.dm-lang.org/proc/switch.md) when using [C-like syntax](https://ref.dm-lang.org/DM/preprocessor/pragma/syntax.md), where it breaks out of a `case` block to the end of the switch. See [switch proc](https://ref.dm-lang.org/proc/switch.md) for more details.

### See also
- [continue statement](https://ref.dm-lang.org/proc/continue.md)
- [do proc](https://ref.dm-lang.org/proc/do.md)
- [for loop proc](https://ref.dm-lang.org/proc/for/loop.md)
- [while proc](https://ref.dm-lang.org/proc/while.md)
- [switch proc](https://ref.dm-lang.org/proc/switch.md)
- [#pragma syntax directive](https://ref.dm-lang.org/DM/preprocessor/pragma/syntax.md)
