When do I use an “OR” vs a || in a ColdFusion cfif statement?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Double pipe (as well as double ampersand) are supported in ColdFusion since CF8. Since learning that, I always use double pipe/double ampersand instead of OR/AND. The reason why I code with this style is that “OR” is not completely descriptive with regards to the operation being performed. There’s bitwise-OR, logical-OR, and logical-OR with short-circuiting.
Bitwise OR:
01 | 10 = 11Logical OR:
buildErrorsOn(form.varA) | buildErrorsOn(form.varB)Logical OR (short-circuit):
isDefined('url.doStuff') || isDefined('url.doStuff')In just about any language you could use right now (Oracle seeming to be a notable exception), double pipe always means Logical-OR with short-circuiting. It’s a precise notation.