+ (addition)
Top  Previous  Next


SWiSH Player Support
SWF4 or later - Supported Internally

Syntax
expression1 + expression2

Arguments
expression1,expression2 numeric constants, string constants or variables.

Returns
Result of the sum of expression1 + expression2 if neither expressions is a string (for SWF4 only, variables are assumed to be numeric).
Result of expression1 add expression2 if either expression is a string.

Description
If both expressions are integers, the sum is an integer. If either or both expressions are floating-point numbers, the sum is a floating-point number. If either expression is a string constant, the result is expression1 add expression2.

Sample
This statement below adds the integers 2 and 3 and displays the resulting integer, 5, in the 'Debug' window:
trace (2
 + 3);

This statement below adds the floating-point numbers 2.5 and 3.25 and displays the result, 5.75, a floating-point number, in the 'Debug' window:
trace (2.5 + 3.25);

This statement below writes the string "1122" to the 'Debug' window"
trace(11 + "22"); // converts both to string because of "22"

onLoad () {
    a = "10";
    b = "eats dog";
    c = "cat ";
    trace(1 + a);
    trace(a + b);
    trace("cat" + " eats dog");
    trace(a add b);
    trace(c add b);
}


Produces the output
11

10

cat eats dog
10eats dog
cat eats dog


See Also
plus, Variables and String Conversion for more information about automatic type conversion of variables.