D KARTHICK
Programmer
Which is faster if-else or Switch case ?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
' if statement - assuming it will only ever be 2 or 5
if x = 5 then
x = 2
else
x = 5
end if
' arithmetic - assuming it will only ever be 2 or 5
x = 7 - x
switch (x)
{
case 8: ...; break;
case 5: ...; break;
case 7: ...; break;
case 6: ...; break;
}