-
-
Save aliaspooryorik/d6a120d7e1c73b1d8aa8d37bf6210fc9 to your computer and use it in GitHub Desktop.
CFML operators
This file contains hidden or 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> | |
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