Created
June 1, 2015 17:57
-
-
Save anonymous/9d104178a7630d198a16 to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
expressions = ["some constant value","a different constant value","third constant value","4th value","5th value","none"]; | |
expression = expressions[randRange(1,expressions.Len())]; | |
writeDump({"expression":expression}); | |
switch (expression){ | |
case "some constant value": // value can be dynamic on Railo/Lucee | |
writeOutput('<h3>statements executed if expression = "some constant value"</h3>'); | |
break; // exit switch statement | |
case "a different constant value": | |
writeOutput('<h3>statements executed if expression = "a different constant value"<br> | |
if there is no break, then processing continues to execute statements until a break is encountered...<br> | |
... but subsequent case evaluations are not made. A switch is basically a GOTO mechanism, which does a... | |
single GOTO the first matching case. It is NOT a series of if/elseif/else statements</h3>'); | |
case "third constant value": | |
writeOutput('<h3>statements executed if expression = "a different constant value" or "third constant value"</h3>'); | |
break; | |
case "4th value": | |
case "5th value": | |
writeOutput('<h3>statements executed if expression is one of "4th value" or "5th value"</h3>'); | |
break; | |
default: | |
writeOutput('<h3>statements executed if no case was fulfilled (or if the last fulfilled case did not have a break)</h3>'); | |
break; | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment