Mathematica > Core Language > Procedural Programming > Conditionals >

If

If[condition, t, f]
gives t if condition evaluates to True, and f if it evaluates to False.
If[condition, t, f, u]
gives u if condition evaluates to neither True nor False.
  • If evaluates only the argument determined by the value of the condition.
  • If[condition, t, f] is left unevaluated if condition evaluates to neither True nor False.
  • If[condition, t] gives Null if condition evaluates to False.
New in 1
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team