If[cond, pos, neg]True, and neg if it evaluates toFalse.If[cond, pos, neg, other]True nor False.If[cond, pos]Null if cond evaluates to False.If[1<2, a, b]
If the second branch is not specified, Null is taken:
If[1<2, a]
If[False, a] // FullForm
You might use comments inside (* and *) to make the branches of If
more readable:
If[a, (*then*) b, (*else*) c];
Since one or more arguments to a boolean operation could be symbolic, it is possible that an If cannot be evaluated. For example:
Clear[a, b]; If [a < b, a, b]
To handle this, If takes an optional fourth parameter:
If [a < b, a, b, "I give up"]