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

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


FilledSmallSquare Switch[expr, , , , , ... ] evaluates expr, then compares it with each of the in turn, evaluating and returning the corresponding to the first match found.

FilledSmallSquare Only the corresponding to the first that matches expr is evaluated. Each is evaluated only when the match is tried.

FilledSmallSquare If the last is the pattern _, then the corresponding is always returned if this case is reached.

FilledSmallSquare If none of the match expr, the Switch is returned unevaluated.

FilledSmallSquare Switch has attribute HoldRest.

FilledSmallSquare You can use Break, Return and Throw in Switch.

FilledSmallSquare See Section 2.6.8.

FilledSmallSquare See also: If, Condition, Which.

FilledSmallSquare New in Version 1.

Further Examples