0
Clarification Please: If-statement VS Switch-statement
I just need some clarification. Are the if-statement and the switch-statement technically interchangeable? If I have a problem that I am solving, I could use either one and then it is just a matter of knowing when to use one versus the other. Is this correct?
2 odpowiedzi
+ 1
Use switch to interact with User or major decisions, use if for fast reasonings in code.
0
when you use if, you could put more conditions to solve your problem like or || and && , so you can put more variables, when you use switch, your datas are more static, like case 0, case 1 and so on, so i think if more flexible to use conditionals