Information Technology Reference
In-Depth Information
Assignment Operators
The assignment operators evaluate the expression on the right side of the operator and use that
value to set the value of the “variable-type” expression on the left side of the operator. As in C
and C++, the value assigned to the left-hand side can be modified if the operator is a compound
assignment operator. The assignment operators are listed in Table 8-14.
The assignment operators are binary and left-associative.
Table 8-14. The Assignment Operators
Operator
Description
=
Simple assignment; evaluate the expression on the right and assign the returned
value to the variable or expression on the left.
*=
Compound assignment; var *= expr is equal to var = var * (expr).
/=
Compound assignment; var /= expr is equal to var = var / (expr).
%=
Compound assignment; var %= expr is equal to var = var % (expr).
+=
Compound assignment; var += expr is equal to var = var + (expr).
-=
Compound assignment; var -= expr is equal to var = var - (expr).
<<=
Compound assignment; var <<= expr is equal to var = var << (expr).
>>=
Compound assignment; var >>= expr is equal to var = var >> (expr).
&=
Compound assignment; var &= expr is equal to var = var & (expr).
^=
Compound assignment; var ^= expr is equal to var = var ^ (expr).
|=
Compound assignment; var |= expr is equal to var = var | (expr).
The syntax is as follows:
VariableExpression Operator Expression
Search WWH ::




Custom Search