Break

Break[]

exits the nearest enclosing Do, For, or While.

Details

  • Break[] takes effect as soon as it is evaluated, even if it appears inside other functions.
  • After a Break the value Null is returned from the enclosing control structure.
  • The function of Break can also be achieved using Throw and Catch.

Examples

open allclose all

Basic Examples  (1)

Break out of the Do when i is larger than 2:

In[1]:=
Click for copyable input

Scope  (1)

Applications  (1)

Properties & Relations  (2)

See Also

Continue  Return  Goto  Abort

Tutorials

Introduced in 1988
(1.0)
| Updated in 1996
(3.0)