Using operators in coldfusion

Using operators in coldfusion

When I started developing (many years ago now) I jumped straight into Coldfusion and HTML. My main role was creating administration's where clients could store the information hey needed to run the flashy front end. As a result I never really touched on any languages that used boolen or string operators.

I first started using these operators in Coldfusion 8. String operators manipulate strings of characters while boolean operators perform logical connective and negation operations. Of course there are ways preforming tasks without these operators in coldfusion but using them will not only make your code neater but also bring your code in line with other programming languages that you may use.

Here are examples of the operators, sourced from the coldfusion documentation

Operator

Description

NOT

or !

Reverse the value of an argument. For example, NOT True is False and the inverse.

AND

or &&

Return True if both arguments are True; return False otherwise. For example, True AND True is True, but True AND False is False.

OR

or ||

Return True if any of the arguments is True; return False otherwise. For example, True OR False is True, but False OR False is False.

XOR

Exclusive or: Return True if one of the values is True and the other is False. Return False if both arguments are True or both are False. For example, True XOR True is False, but True XOR False is True.

EQV

Equivalence: Return True if both operands are True or both are False. The EQV operator is the opposite of the XOR operator. For example, True EQV True is True, but True EQV False is False.

IMP

Implication: The statement A IMP B is the equivalent of the logical statement “If A Then B.” A IMP B is False only if A is True and B is False. It is True in all other cases.

Operator

Description

&

Concatenates strings.

&=

Compound concatenation. The variable on the right is used as both an element in the concatenation operation and the result variable. Thus, the expression a &= b is equivalent to a = a & b.

An expression can have only one compound assignment operator.

 

comments powered by Disqus