0
Switch satement vs. for loop
Could the switch statement be seen as a specialized for loop?
4 RĂ©ponses
+ 3
No switch can be use to avoid writing multiple if else statement.
+ 1
That makes no sense. Yes it can be seen as alternate to if-else statements tho
0
G'day Joseph Edward Barry as the other have said, the đswitch case() breakđ commands are not a loop.
However, I think đdo while() continue breakđcould be considered an alternative to a đfor(;;;) continue breakđ loop.
Both check (condition) before looping again, both can have an increment that will meet the condition, both can continue or break, both should have an initialisation before running the loop.