This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
 BUILT-IN MATHEMATICA SYMBOL Tutorials »| See Also »| More About »

# If

 Ifgives t if condition evaluates to True, and f if it evaluates to False. Ifgives u if condition evaluates to neither True nor False.
• If evaluates only the argument determined by the value of the condition.
• If is left unevaluated if condition evaluates to neither True nor False.
 Out[2]=
 Scope   (4)
If the condition is neither True nor False, If remains unevaluated:
The form with an explicit case for an undetermined condition evaluates in any case:
Use TrueQ to force the condition to always return a Boolean value:
Define a piecewise function with both If and Round as piecewise elements:
Use PiecewiseExpand to get it into piecewise normal form:
Perform several different symbolic operations:
If can be used as a statement:
It can also be used as an expression returning a value:
Only the branch actually taken is evaluated:
Define a function by cases:
Alternatively, use several conditional definitions:
Use Which rather than a nested if-then-elsif chain:
Use PiecewiseExpand to convert If to Piecewise:
New in 1