Adobe ColdFusion 8

Decision operators

The ColdFusion decision, or comparison, operators produce a Boolean True/False result. Many types of operation have multiple equivalent operator forms. For example, IS and EQ perform the same operation. The following table describes the decision operators:

Operator

Description

IS

EQUAL

EQ

Perform a case-insensitive comparison of two values. Return True if the values are identical.

IS NOT

NOT EQUAL

NEQ

Opposite of IS. Perform a case-insensitive comparison of two values. Return True if the values are not identical.

CONTAINS

Return True if the value on the left contains the value on the right.

DOES NOT CONTAIN

Opposite of CONTAINS. Return True if the value on the left does not contain the value on the right.

GREATER THAN

GT

Return True if the value on the left is greater than the value on the right.

LESS THAN

LT

Opposite of GREATER THAN. Return True if the value on the left is smaller than the value on the right.

GREATER THAN OR EQUAL TO

GTE

GE

Return True if the value on the left is greater than or equal to the value on the right.

LESS THAN OR EQUAL TO

LTE

LE

Return True if the value on the left is less than or equal to the value on the right.

Note: In CFScript expressions only, you can also use the following decision operators. You cannot use them in expressions in tags. == (EQ), != (NEQ), > (GT), < (LT), >= (GTE), and <= (LTE).

Decision operator rules

The following rules apply to decision operators:

  • When ColdFusion evaluates an expression that contains a decision operator other than CONTAINS or DOES NOT CONTAIN, it first determines if the data can be converted to numeric values. If they can be converted, it performs a numeric comparison on the data. If they cannot be converted, it performs a string comparison. This can sometimes result in unexpected results. For more information on this behavior, see Evaluation and type conversion issues.
  • When ColdFusion evaluates an expression with CONTAINS or DOES NOT CONTAIN it does a string comparison. The expression A CONTAINS B evaluates to True if B is a substring of A. Therefore an expression such as the following evaluates as True:
    123.45 CONTAINS 3.4

  1. When a ColdFusion decision operator compares strings, it ignores the case. As a result, the following expression is True:
    "a" IS "A"

  2. When a ColdFusion decision operator compares strings, it evaluates the strings from left to right, comparing the characters in each position according to their sorting order. The first position where the characters differ determines the relative values of the strings. As a result, the following expressions are True:
"ab" LT "aba"
"abde" LT "ac"