Symbols > += (addition assignment) |  |

+= (addition assignment)

addition assignment, plus, +=

Availability

Flash Player 4.

Usage

    expression1 += expression2

Parameters

`expression1,expression2` A number or string.

Returns

Nothing.

Description

Operator (arithmetic compound assignment); assigns `expression1` the value of `expression1` `+` `expression2`. For example, the following two statements have the same result:

    x += y;
    x = x + y;

This operator also performs string concatenation. All the rules of the addition operator `(+)` apply to the addition assignment `(+=)` operator.

Example

The following example shows a numeric use of the `+=` operator.

    x = 5;
    y = 10;
    x += y;
    trace(x);
    //x returns 15

This example uses the`+=` operator with a string expression and sends "My name is Gilbert" to the Output window.

    x = "My name is "
    x += "Gilbert"
    trace (x)

See also

`+ (addition)`