Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?

Logical Operators

There are two binary logical operators, which allow you to evaluate complex conditions comprising multiple simple conditions. There is also a unary logical operator, which reverses the value of a condition. When building complex conditions, remember to always use parentheses to clarify the meaning of the expression.

Logical Operators
Operator Operation Examples of true conditions
&& And. All conditions must be true for the entire condition to be true. if (2 = 2) && (3 = 3) {write "both are true"}
|| Or. At least one of the conditions must be true (or both) for the entire condition to be true. if (2 = 2) || (3 = 4) {write "one is true"}
' Negation (Not). The original condition must be false for the negated condition to be true. if '(2 = 3) {write "unequal"}