This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Switch

Switch
evaluates expr, then compares it with each of the in turn, evaluating and returning the corresponding to the first match found.
  • Only the corresponding to the first that matches expr is evaluated. Each is evaluated only when the match is tried.
  • If the last is the pattern , then the corresponding is always returned if this case is reached.
  • If none of the match expr, the Switch is returned unevaluated.
Process Boolean value to 1 or 0, giving a message and defaulting to 0 when not Boolean:
Give a suggested symbolic transformation for an expression:
Try the transformation:
Process Boolean value to 1 or 0, giving a message and defaulting to 0 when not Boolean:
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=
 
Give a suggested symbolic transformation for an expression:
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
Try the transformation:
In[3]:=
Click for copyable input
Out[3]=
New in 1