To be fair, I had to read the linked question on SO to understand what was the possible alternative. I do expect that if I use += it is in place.
On the other hand with Python and Java I always keep forgetting if everything is by value or by reference, I really miss some extra clarity of the languages where you can see if something is mutable when passed to a function
The fact that
x += y
modifieslist
s in place might be surprising if you’re expecting it to be exactly equivalent tox = x + y
.Yes, that is a surprise to many, in other languages ‘x+=y’ and ‘x=x+y’ are the same.
To be fair, I had to read the linked question on SO to understand what was the possible alternative. I do expect that if I use
+=
it is in place.On the other hand with Python and Java I always keep forgetting if everything is by value or by reference, I really miss some extra clarity of the languages where you can see if something is mutable when passed to a function