\ifcase doesn't work like the switch statement in other languages, in which you choose what values have a branch of their own. The syntax of \ifcase is:
\ifcase<number>
<case 0>
\or <case 1>
\or <case 2>
\or <as many as you want>
\else <other cases>
\fi
you can't skip a value. In your code you'd need:
\foreach \x in {10, 9,..., 0}
{
\ifcase\x \relax
% 0
\or % 1
\or % 2
\or % 3
\or % 4
\or % 5
\node[] {\x};
\or % 6
\or % 7
\or % 8
\or % 9
\or % 10
\else % other cases
\fi
}
which is a handful. For a small number of exceptions you could use \ifnum:
\foreach \x in {10, 9,..., 0}
{
\ifnum\x=5 \relax
\node[] {\x};
\else\ifnum\x=10 \relax
% do things with \x=10
\else
% possibly more cases
\fi\fi
}
which can become a mess, once you have more than a couple of cases.
My suggestion: \int_case:nnF. You can specify each case individually and a false branch in case no other is taken:
\documentclass{article}
\usepackage{tikz}
\usepackage{expl3}
\ExplSyntaxOn
\cs_new_eq:NN \IntCasennF \int_case:nnF
\ExplSyntaxOff
\begin{document}
\begin{tikzpicture}
\foreach \x in {10, 9,..., 0}
{
\IntCasennF {\x}
{
{5}{\node[] {\x};}
{10}{<Code for 10>}
}
{<Other cases>}
}
\end{tikzpicture}
\end{document}
\ifnum\x=10instead of\if \x10. – Sep 26 '19 at 18:19\ifcasedoesn't do a comparison, it just takes a number.\ifcase\x\relax <case 0>\or <case 1>\or <case 2>\or... \else <other cases>\fi. – Phelype Oleinik Sep 26 '19 at 18:22\ifcaseof course. What does this have to do with\ifnumvs.\if? See @PhelypeOleinik comment.\ifcasegoes through the integers one by one, starting from 0. – Sep 26 '19 at 18:23