Skip to content

Commit 7fdc860

Browse files
committed
Simplify wording and rework example as doctest
1 parent e244107 commit 7fdc860

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

doc/manual/mathematical-operations.rst

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,21 @@ 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-
125+
.. note::
126+
Updating operators may change the type of the variable, since any assignment
127+
statement to a plain variable may change its type.
128+
129+
.. doctest::
130+
131+
julia> x = 0x01; typeof(x)
132+
Uint8
133+
134+
julia> x *= 2 #Same as x = x * 2
135+
2
136+
137+
julia> isa(x, Int)
138+
true
139+
136140
.. _man-numeric-comparisons:
137141

138142
Numeric Comparisons

0 commit comments

Comments
 (0)