GOOC - Game Oriented Object C
GOOC - Game Oriented Object C
7.1. Assignment Operators
7.1. Assignment Operators
Assignment operators store values in variables. GOOC provides several variations of assignment operators.
The standard assignment operator = simply stores the value of its right operand in the variable specified by its left operand. As with all assignment operators, the left operand (commonly referred to as the "lvalue") must be a valid "address", that is, it cannot be a literal or constant value, or any expression that requires evaluation.
Compound assignment operators perform an operation involving both the left and right operands, and then assign the resulting expression to the left operand. Since the left operand of any assignment is an address that cannot be evaluated, compound assignments are merely syntactic sugar. Here is a list of the compound assignment operators, and the expression they unroll to:
- foo += bar is equivalent to foo = foo + bar
- foo -= bar is equivalent to foo = foo - bar
- foo *= bar is equivalent to foo = foo * bar
- foo /= bar is equivalent to foo = foo / bar
- foo %= bar is equivalent to foo = foo % bar
- foo <<= bar is equivalent to foo = foo << bar
- foo >>= bar is equivalent to foo = foo >> bar
- foo &= bar is equivalent to foo = foo & bar
- foo |= bar is equivalent to foo = foo | bar
- foo ^= bar is equivalent to foo = foo ^ bar
- foo \= bar is equivalent to foo = foo \ bar