Script [6.11.1]:
set cards to {"deck"}
set cartoon to "dragon ball z"
set playingCards to cards & cartoon
Explanation: This is an example where we merge cards and cartoon to playingCards. The fundamental question here is, what is the data type of playingCards.
cards is of type list and cartoon is of type string.
If you observe closely the third statement says cards & cartoon
As cards has been specified first, playingCards will inherit the data type of cards that is list.
Figure 6.11.1 Meging Different Types
If the third statement of Script was,
set playingCards to cartoon & cards
then output would have been,
Figure 6.11.1-2 Merging Different Types
The data type of playingCards is String. This is because cartoon was the first term used in merging. And because it is String type, the contents of cards gets added with contents of cartoon.
Script [6.11.2]:
set cards to {"deck"}
set cartoon to "dragon ball z"
set playingCards to (cartoon as list) & cards
Explanation: This is an example where we merge cards and cartoon to playingCards. But there is a problem. I want data in the variable playingCards to be of type list.
cards is of type list and cartoon is of type string. If you observe closely the third statement says (cartoon as list). This command will convert cartoon from string to list (coercion). Now it does not matter what data type the subsequent variables are of. playingCards will be of type list.
Figure 6.11.2 Merging With Coercion