+ 1
How can I add || to chars in switches?
Code like this won't work :/ switch(letter) { case 'e' || 'E' || 'i' || 'I' || 'o' || 'O' || 'n' || 'N' || 'r' || 'R' : score++; break; ... }
1 Odpowiedź
+ 3
You only can use constant for case, not an expression.
But you can use falltrough to achieve the same result
case 'e':
case 'E':
//Do something
break;