0

Switch satement vs. for loop

Could the switch statement be seen as a specialized for loop?

7th Mar 2022, 2:55 PM
Joseph Edward Barry
3 ответов
+ 3
No switch can be use to avoid writing multiple if else statement.
7th Mar 2022, 2:58 PM
A͢J
A͢J - avatar
+ 1
That makes no sense. Yes it can be seen as alternate to if-else statements tho
7th Mar 2022, 7:09 PM
Aaron Stone
Aaron Stone - avatar
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.
7th Mar 2022, 11:20 PM
HungryTradie
HungryTradie - avatar