returns the argument of the first Throw generated in the evaluation of expr.
returns value from the first Throw[value,tag] for which form matches tag.
- Catch[expr,…] always returns the value of expr if no Throw was generated during the evaluation.
- form can be any expression, and is often a pattern.
- tag in Throw[value,tag] is re‐evaluated every time it is compared to form.
Basic Examples (3)
Exit to the enclosing Catch as soon as the Throw is evaluated:
Define a function that can "throw an exception":
The result of the Catch is just what is thrown by Throw:
Use Throw to exit a loop when a criterion is satisfied:
Generalizations & Extensions (3)
Properties & Relations (1)
Introduced in 1988
Updated in 1996