Language Guide
CHAPTER 6
Expressions
178 Operations
ALL OTHER CLASSES
The concatenation of two operands that are not strings or records is a list
whose first item is the value of the operand to the left of the operator, and
whose second item is the value of the operand to the right of the operator.
If the operands to be concatenated are lists, then the result is a list containing
all the items in the list to the left of the operator, followed by all the items in
the list to the right of the operator. For example,
{ "This" } & { "and", "that" }
returns a list containing three items:
{ "This", "and", "that" }
Operator Precedence 6
AppleScript allows you to combine expressions into larger, more complex
expressions. When evaluating expressions, AppleScript uses operator
precedence to determine which operations are performed first. Table 6-2 shows
the order in which AppleScript performs operations.
To see how operator precedence works, consider the following expression.
2 * 5 + 12
--result: 22
To evaluate the expression, AppleScript performs the multiplication operation
2 * 5 first, because as shown in Table 6-2, multiplication has higher
precedence than addition.
The column labeled “Associativity” in Table 6-2 indicates the order in which
AppleScript performs operations if there are two or more operations of the
same precedence in an expression. The word “none” in the Associativity
column indicates that you cannot have multiple consecutive occurrences of the
operation in an expression. For example, the expression 3 = 3 = 3 is not
legal because the associativity for the equal operator (=) is “none.” The word
“unary” indicates that the operator is a unary operator. To evaluate expressions
with multiple unary operators of the same order, AppleScript applies the
operator closest to the operand first, then applies the next closest operator, and
so on. For example, the expression not not not true is evaluated as
not (not (not true)).