+ 1
Inside a case I can place the logical operators "or, and, not"?
2 Respostas
+ 4
On its inner statement block, yes, but not in the case condition. However, there are ways you can go about the OR operator.
case 1:
case 2:
case 3:
// my code
break;
^That is basically saying if it's case 1 OR 2 OR 3, then do this code. If you want something to happen if it's NOT any of those, place it inside of the default section of your switch. Switch is good for what it does, but it's not the best option for all situations.
0
thank you for clarifying my doubts, it helped me a lot :)