Operator | Compatible types | Description |
= | All |
Assigns the right-hand side value to the left-hand side, and returns the right-hand side value:
var x = 45.6; Note that irScript values obey CLR assignment semantics (value types assign-by-value, reference types assign-by- reference… ScriptObject, ScriptCollection, and ScriptFunction are all reference types). |
+= | Integer, Decimal, Text |
For numerics, adds the lhs and rhs values and assigns the result to lhs. For text values, concatenates lhs with rhs and assigns the result to lhs. The resulting value is returned:
var x = 45.6; x += 10; |
-= | Integer, Decimal |
Subtracts the lhs and rhs values and assigns the result to lhs. The resulting value is returned:
var x = 45.6; x -= 10; |
*= | Integer, Decimal |
Multiplies the lhs and rhs values and assigns the result to lhs. The resulting value is returned: var x = 45.6; x -= 10; |
/= | Integer, Decimal |
Divides the lhs value by the rhs value and assigns the result to lhs. The resulting value is returned:
var x = 45.6; x /= 10; |
%= | Integer, Decimal |
Divides the lhs value by the rhs value and assigns the remainder to lhs. The resulting value is returned:
var x = 45; x %= 10; |
&= | Integer |
Performs a bitwise ‘and’ operation between lhs and rhs, and assigns the value to lhs. The resulting value is returned:
var x = 4; x &= 3; |
|= | Integer |
Performs a bitwise ‘or’ operation between lhs and rhs, and assigns the value to lhs. The resulting value is returned:
var x = 4; x |= 3; |
^= | Integer |
Performs a bitwise ‘xor’ operation between lhs and rhs, and assigns the value to lhs. The resulting value is returned:
var x = 4; x ^= 3; |
<<= | Integer |
Shifts the lhs value by rhs bits to the left, and assigns the value to lhs. The resulting value is returned:
var x = 45; x <<= 2; |
>>= | Integer |
Shifts the lhs value by rhs bits to the right, and assigns the value to lhs. The resulting value is returned:
var x = 45; x >>= 2; |
Assignment
- Updated
Was this article helpful?
0 out of 0 found this helpful
Comments
0 comments
Please sign in to leave a comment.