Switch
[expr, $pattern_1$, $value_1$, $pattern_2$, $value_2$, ...]Switch[2, 1, x, 2, y, 3, z]
Switch[5, 1, x, 2, y]
Switch[5, 1, x, 2, a, _, b]
Switch[2, 1]
Notice that Switch
evaluates each pattern before it against expr, stopping after the first match:
a:=(Print["a->p"];p); b:=(Print["b->q"];q);
Switch[p,a,1,b,2]
a=.; b=.;