by Simon. Average Reading Time: less than a minute.
In addition to the comparison operators, which can be used on string values, the concatenation operator (&) concatenates two string values together, returning another string that is the union of the two operand strings. For example, “my ” & “string” returns the string “my string”.
The shorthand assignment operator &= can also be used to concatenate strings. For example, if the variable mystring has the value “alpha”, then the expression mystring &= “bet” evaluates to “alphabet” and assigns this value to mystring. This expression can be used in all CFML expressions.
comparison operators, which can be used on string values, the concatenation operator (&) concatenates two string values together, returning another string that is the union of the two operand strings. For example, “my ” & “string” returns the string “my string”.
" title="LinkedIn">LinkedIn
An assignment operator assigns a value to its left operand based on the value of its right operand.
The basic assignment operator is equal (=), which assigns the value of its right operand to its left operand. That is, x = y assigns the value of y to x. The other assignment operators are usually shorthand for standard operations, as shown in the following table.
An often mentioned complaint by ColdFusion developers is the lack of operators commonly found in other programming languages such as JavaScript. For example, instead of the greater-than (>) symbol we have been restricted to the more wordy GT or GREATER THAN operator. However, in ColdFusion 8 this has changed and we have more freedom to use familiar JavaScript operators in <cfscript> blocks.
In the following series of posts, I will introduce the changes and show some simple examples. The first in the series is Arithmetic Operators.
Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value. The standard arithmetic operators are addition (+), subtraction (-), multiplication (*), and division (/).
These operators work as they do in most other programming languages.
Logical operators are typically used with Boolean (logical) values; when they are, they return a Boolean value. However, the && and || operators actually return the value of one of the specified operands, so if these operators are used with non-Boolean values, they may return a non-Boolean value.