Considering it rapidly speeds up your conditional statements, I will always use a switch statement. A switch statement acts as though you are accessing an array via an index. Whereas an elseif statement has to process each conditional statement until it passes.
Considering it rapidly speeds up your conditional statements, I will always use a switch statement. A switch statement acts as though you are accessing an array via an index. Whereas an elseif statement has to process each conditional statement until it passes.
Of course this depends on the context of the application though. If I am checking against static values, then my previous statement is true.
Depends on if scripted Vs compiled.
A compiler will optimise into either the conditions or a jump table depending on the code. Usually for both switch and if else
As someone who has never had the chance to jump into a compiled language, this is wonderful information! Thank you for the correction.