0

Does the statement contained in a case statement be executed if the case doesn't match?

I think this is supposed to be a stupid question. But while playing with the code, i made something that seemed to me somewhat weird. You can check this code: https://code.sololearn.com/cU6LHwS56vH1/?ref=app Thanks in advance!

19th Jun 2019, 10:31 PM
Gid
Gid - avatar
3 Respuestas
+ 1
Yes in this case the default case is operated
20th Jun 2019, 12:39 AM
Lexfuturorum
Lexfuturorum - avatar
0
Lexfuturorum So you mean it will execute every thing until it sees a break statement, so i have to put my "cases" in a specific order to get the result i want?
20th Jun 2019, 1:14 AM
Gid
Gid - avatar
0
No they don't have to be in a specific order the switch statement is kind of an else if statement the default case is the else at the end.
20th Jun 2019, 2:12 AM
Lexfuturorum
Lexfuturorum - avatar