4 ms·
The section on assignment operators is incorrect. x += y modifies the object x, whereas x = x + y doesn't. For example, >> a = [1, 2, 3] >> b = a >> a
by trombonechamp 8y ago
The section on assignment operators is incorrect. x += y modifies the object x, whereas x = x + y doesn't. For example,
>> a = [1, 2, 3]
>> b = a
>> a += [4]
>> a
[1, 2, 3, 4]
>> b
[1, 2, 3, 4]
By comparison,
>> a = [1, 2, 3]
>> b = a
>> a = a + [4]
>> a
[1, 2, 3, 4]
>> b
[1, 2, 3]
- bhishan 8y agoThis is especially true for the case of mutables. I agree it should've been mentioned on the blog. Do you mind if I add this thread to the comments section of the blog.