Switch

\resizebox{!}{2ex}{\includegraphics{images/switchIcon.eps}} A switch block (also known as a case block, or select in the Fortran world) is a way of selecting from a range of alternatives according to the value of the input, effectively defining a piecewise function.

\resizebox{\textwidth}{!}{\includegraphics{images/switch.eps}} An example switch block with 3 cases

The default switch has two cases, and can be used to implement an if/then/else construct. However, because the two cases are 0 and 1, or false and true, a two case switch statement will naturally appear “upside down” to how you might think of an if statement. In other words, it looks like:

$\textstyle \parbox{\textwidth}{
{\tt if not }{\em condition} {\tt then}\\
\ldots
{\tt else}\\
\ldots }$

You can add or remove cases through the context menu.