Skip to content

Which

Which[cond, res, cond, res, ...] tries each cond in sequence and returns the corresponding result if True.

Attributes[Which] := {HoldAll, Protected}

Simple examples

In[1]:= Which[(1) > (2), a, (1) < (2), b]
Out[1]= b
In[2]:= Which[(2) > (2), a, (2) < (2), b]
Out[2]= Null