Chapter 15. Operators
An operator is a token that transforms a value or a pair of values to produce a new value. These transformations are operations, and the values operated upon are the operands. An operator with two operands is binary; an operator with one operand is unary. This chapter lists the AppleScript operators and explains what they do, with special attention to implicit coercions performed by the operators. It also talks about parentheses, because they help determine the effects of the operators. Finally, there's a section on the differences between what happens when AppleScript performs an operation and when a scriptable application performs it.
(For the coercion operator, as
, see Chapter 14; for the object containment operator, of
, see Chapter 11.)
Implicit Coercion
In Chapter 14, I explained coercion and described the coercions that are possible between built-in datatypes in the AppleScript language. Binary operators can (and will) perform coercion without your specifically asking for it. This is called implicit coercion , and is one of the most confusing aspects of AppleScript—and a frequent source of mistakes in scripts. If you are not prepared for what implicit coercions an operator will perform, you will be surprised when the result of an operation is not what you expected. That's why this chapter spends so much time on the implicit coercions performed by the various operators.
What coercions AppleScript will perform implicitly is not the same as what coercions you ...
Get AppleScript: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.