+ 3

Using of switch/case

For example, if all the statements in the code are true and all of them are possible and match, how do I choose which case will be printed at first place? Or will all of them be printed?

26th Nov 2016, 9:08 PM
Julia Melnik
Julia Melnik - avatar
2 Answers
+ 2
The default case will be printed, unless you choose not to use the "break" keyword. I would say that If statements are more suitable for this kind of conditional; since switch is more used to checking values.
26th Nov 2016, 9:51 PM
LaserVision
0
The order the cases are provided is the order they'll be evaluated. If the first case is true, the evaluation will conclude without assessing the other cases and return.
26th Nov 2016, 9:45 PM
Chris McKinney
Chris McKinney - avatar