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?

16th Oct 2016, 6:02 AM
Lourdes Marie Walker
Lourdes Marie Walker - avatar
2 Answers
+ 1
Use switch to interact with User or major decisions, use if for fast reasonings in code.
24th Oct 2016, 10:00 PM
Salin Naun
Salin Naun - avatar
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
22nd Oct 2016, 4:26 PM
Neo
Neo - avatar