+ 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; ... }

31st Dec 2018, 1:45 AM
Gino ^^
Gino ^^ - avatar
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;
31st Dec 2018, 2:04 AM
Taste
Taste - avatar