I am creating a handout with a command that hides the answers for students and reveals the answers for instructors. I defined a new command invisible that takes a bool and text. If 0, the text should be untouched. If 1, the text should be printed in white, making it invisible on paper. However in this example the text is printed regardless of the bool. I created another command altinvisible where the text is not a parameter. It did not solve the problem. What is wrong here?
\documentclass{article}
\usepackage{tikz}
\newcommand{\invisible}[2]{\ifcase#1\or\expandafter\textcolor{white}\fi{#2}}
\newcommand{\altinvisible}[1]{\ifcase#1\or\expandafter\textcolor{white}\fi}
\title{}
\author{}
\begin{document}
{3.14}
\textcolor{white}{3.14}
\invisible{0}{3.14}
\invisible{1}{3.14}
\altinvisible{0}{3.14}
\altinvisible{1}{3.14}
\end{document}