<< operator for arrays

Actually, neither += nor *= nor any of the similar operators is mutating in general. They all create a new value which is independent of the previous values because:

x += y

is transformed into

x = x + y

which creates a new value which just happens to also be called x.

This is a common misconception about Julia because those operators are mutating in many languages, like Python for example.

11 Likes