+ 1

Inside a case I can place the logical operators "or, and, not"?

12th Dec 2017, 1:41 PM
kenyi lópez
kenyi lópez - avatar
2 Respuestas
+ 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.
12th Dec 2017, 1:52 PM
AgentSmith
0
thank you for clarifying my doubts, it helped me a lot :)
14th Dec 2017, 4:11 AM
kenyi lópez
kenyi lópez - avatar