The following code does not compile if I don't have the extra braces around the entries of the matrix, and I don't know why. Can I modify \switcher to obviate the need for these extra braces?
\documentclass{article}
\usepackage{amsmath}
\newcommand{\switcher}[2][]
{
\ifx&%
#2
\else
#1
\fi
}
\begin{document}
\[
\begin{bmatrix}
{\switcher{2}} \\
{\switcher[1]{2}}
\end{bmatrix}
\]
\end{document}
