Forgetting a break; | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Forgetting a break;

Forgetting a break it will just run the cases until it hits a break so it won run them all correct but if you run more then one case will it run until it finds 2 breaks? case a: case b: case c: break; case d: break; so if you call case a and case b

1st Nov 2016, 8:04 PM
Aaron Wilder
Aaron Wilder - avatar
1 Réponse
+ 1
A switch statement will run until it reaches a break, or until it has gone through every case (if there are no breaks), so yes, if case A or B is executed, it will finish at case C, because that's the closest break.
1st Nov 2016, 8:41 PM
Cohen Creber
Cohen Creber - avatar