Skip to content

Instantly share code, notes, and snippets.

Created April 10, 2016 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/c9677002b5544b6c5cc5c3c7421ee7aa to your computer and use it in GitHub Desktop.
Save anonymous/c9677002b5544b6c5cc5c3c7421ee7aa to your computer and use it in GitHub Desktop.
CFML operators
<cfscript>
function operatorTest(a, b) {
var result = {
"#a# || #b#": a || b,
"#a# && #b#": a && b,
"#a# XOR #b#": a XOR b,
"#a# IMP #b#": a IMP b,
"#a# ? #b# : false": a ? b : true,
"#a# EQV #b#": a EQV b,
"#a# == #b#": a == b
};
return result;
}
WriteDump(operatorTest(true, true));
WriteDump(operatorTest(true, false));
WriteDump(operatorTest(false, false));
WriteDump(operatorTest(false, true));
WriteDump(operatorTest("yes", true));
WriteDump(operatorTest("no", false));
WriteDump(operatorTest("false", "no"));
WriteDump(operatorTest(0, 0));
WriteDump(operatorTest(1, 1));
WriteDump(operatorTest(10, 10));
WriteDump(("ten" EQ "ten"));
try {
WriteDump(("ten" EQV "ten"));
} catch (any e) {
WriteDump(e.message);
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment