Skip to content

Commit e244107

Browse files
StephenVavasisjiahao
authored andcommitted
Update mathematical-operations.rst
I added a note that the updating-operators can change the type. This is implicit in the current manual, but it nonetheless threw me for a loop the first time it happened to me (this is different, e.g., from C++), so I thought it should be made explicit.
1 parent 75cff03 commit e244107

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

doc/manual/mathematical-operations.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ are::
122122
+= -= *= /= \= %= ^= &= |= $= >>>= >>= <<=
123123

124124

125+
It should be noted that updating operators can change the type of the variable. For example, after the first
126+
statement below, ``x`` is of type ``Uint32``, but after the second statement, it is of type ``Int``::
127+
128+
129+
x = 0x00000001
130+
x *= 2
131+
132+
133+
This is in consistent with the equivalence between ``x *= 2`` and ``x = x * 2``: any assignment statement to
134+
a plain variable may change its type.
135+
125136
.. _man-numeric-comparisons:
126137

127138
Numeric Comparisons

0 commit comments

Comments
 (0)