+ 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 Resposta
+ 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
Quente hoje
.
1 Votes
What?
0 Votes
HTML
0 Votes
Web
0 Votes
Quiz duel
0 Votes
FRC Coding?
1 Votes
AI
2 Votes
help
0 Votes
APIs
1 Votes