Joe Maller.com

Note about AppleScript records

When combining an existing AppleScript record with another overlapping record, the order of concatenation matters. Consider this example:

set breakfast to {food:"toast", drink:"coffee"}
set lunch to breakfast & {food:"sandwich"}

--- lunch is {food:"toast", drink:"coffee"}

Because breakfast comes before lunch (naturally, when I get to eat breakfast), food is already defined and isn’t recast by the new record. So we get toast for lunch.

Flipping the order of how the lunch record is built gives the expected result, and a better lunch:

set breakfast to {food:"toast", drink:"coffee"}
set lunch to {food:"sandwich"} & breakfast

--- lunch is {food:"sandwich", drink:"coffee"}