Created
June 1, 2015 17:43
-
-
Save anonymous/79d1a9adeea8c2b3d0b6 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> | |
// randomly set truthy/falsy | |
booleanExpression = !!randRange(0,1); | |
anotherBooleanExpression = !!randRange(0,1); | |
writeOutput('<h2>Single statements - no curlies</h2>'); | |
writeDump({"inputs":{"booleanExpression":booleanExpression,"anotherBooleanExpression":anotherBooleanExpression}}); | |
if (booleanExpression) | |
writeOutput( "'booleanExpression' was true" ); // single statement executed if booleanExpression is true | |
else if(anotherBooleanExpression) | |
writeOutput( "'anotherBooleanExpression' was true" ); // single statement executed if anotherBooleanExpression is true | |
else | |
writeOutput( "Neither 'anotherBooleanExpression' or 'booleanExpression' were true" ); // single statement executed if condition(s) are false | |
// randomly set truthy/falsy | |
booleanExpression = !!randRange(0,1); | |
anotherBooleanExpression = !!randRange(0,1); | |
writeOutput('<h2>Multiple statements - with curlies</h2>'); | |
writeDump({"inputs":{"booleanExpression":booleanExpression,"anotherBooleanExpression":anotherBooleanExpression}}); | |
if (booleanExpression) { | |
writeOutput( "'booleanExpression' was true" ); // multiple statements executed if booleanExpression is true | |
} else if(anotherBooleanExpression) { | |
writeOutput( "'anotherBooleanExpression' was true" ); // multiple statements executed if anotherBooleanExpression is true | |
} else { | |
writeOutput( "Neither 'anotherBooleanExpression' nor 'booleanExpression' were true" ); // multiple statements executed if condition(s) are false | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment