There is a variation on the assignment statement, called compound assignment, that simplifies the
coding of a certain type of assignment operations. For example,
x = x+10;
can be written as
x += 10;
The operator += tells the compiler to assign to x the value of x plus 10.
Compound assignment operators exist for all the binary operators (those that require two operands).
In general, statements like
var = var operator expression
Wednesday, August 27, 2008
Compound Assignments
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment