This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Documentation / Mathematica / Built-in Functions / Programming / Flow Control /

Throw

FilledSmallSquare Throw[value] stops evaluation and returns value as the value of the nearest enclosing Catch.

FilledSmallSquare Throw[value, tag] is caught only by Catch[expr, form] where form is a pattern that matches tag.

FilledSmallSquare You can use Throw and Catch to exit functions such as Nest, Fold, FixedPoint and Scan.

FilledSmallSquare tag can be any expression.

FilledSmallSquare tag in Throw[value, tag] is re-evaluated every time it is compared to form in Catch[expr, form].

FilledSmallSquare An error is generated and an unevaluated Throw is returned if there is no appropriate enclosing Catch to catch the Throw.

FilledSmallSquare See Section 2.6.9.

FilledSmallSquare See also: Return, Goto, Interrupt, Abort, Sow.

FilledSmallSquare New in Version 1; modified in 3.

Further Examples