Team LiB   Previous Section   Next Section
&

Syntax

"Use this operator  " & "to concatenate two strings."

Return value

A string if the left operand is a string; a record if the left operand is a record; a list if the left operand is another value type

Description

The concatenation operator can be used to combine two values to produce a single third value combining the operator's two operands. You will mostly use this operator for string concatenation. However, it is also often used to add to records or lists. Make sure not to confuse this operator with the + symbol, which is the concatenation operator of Java and JavaScript that is only used for addition and scientific notation (e.g., 1.2e+6) in AppleScript.

Examples

"My age is dare I say " & 43 (* combining a string and a number returns a

string as in "My age is dare I say 43" *)



{"apples","oranges"} & {"bananas"} (*combine two lists to make one list: 

{"apples","oranges","bananas"} *)



{name: "Pedro Martinez",record: "23-4"} & {award:"Cy Young"} (*add a new 

item to a record, returning {name:"Pedro Martinez", record:"23-4", award:"Cy 

Young"} *)



1.4 & 2 (* returns {1.4,2}. Looks weird, but you might want to store a 

long list of numbers in a list value type, then it doesn't seem so weird.*)



"Your AppleScript version is " & version (* Some concatenation operations 

fail and need some massaging; "Your AppleScript version is " & (version 

as string) will solve this problem *)
    Team LiB   Previous Section   Next Section