Basics of AppleScript

Coercion

Script [6.10.1]:

set bank to "money in the bank"
set myBankList to bank as list

Explanation: Coercion allows us to convert variables from one type to another. In the above example I have created a variable bank which of String type. I then went on to create another variable named myBankList which contains the contents of bank. However a condition is specified. The condition says, when the contents of bank are being copied to myBankList, copy them as a list.

Figure 6.10.1

Figure 6.10.1 String To List

If the second statement did not specify as list that is,

set myBankList to bank

then output would be,

Figure 6.10.1-2

Figure 6.10.1-2 Output Without Coercion

The output no longer shows curly braces. This indicated no coercion has been performed.