Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello all,
Can anybody please show an example of Switch Case statement and how it works with an intermediate-advanced example for some data?
I would like to understand it better
The switch is a script control structure that functions like a series elseif statements:
if ... then ...
elseif ...
elseif ...
elseif ...
...
else ...
end if
switch <expression>
case 1 // execute if statement evaluates to 1
...
case 2 // execute if statement evaluates to 2
...
default // execute if no case statement match (like a final "else")
...
end switch
Unlike mainstream programming languages, there is no "break" statement. Each "case" is an implicit break for the case above.
PS - I don't think i have ever used it in a real application, but YMMV
Hi,
Thank you for the replies but I am still not finding a practical example. Could someone share a practical one please?
Why would you use Switch Case statements? What are the advantages and disadvantages of this function?