If

If[cond, iftrue, iffalse] returns iftrue if cond is True, and iffalse if cond is False.

Attributes[If] := {HoldRest, Protected}

Simple examples

In[1]:= x=9
Out[1]= 9
In[2]:= If[x+3==12, x*2, x+3]
Out[2]= 18
In[3]:= If[x+3==11, x*2, x+3]
Out[3]= 12

Further examples

Undefined conditions leave the statement unevaluated.

In[1]:= If[undefined, a, b]
Out[1]= If[undefined, a, b]