Skip to content

Commit c95ba00

Browse files
authored
a+=b vs a=a+b : clarify the difference is not universal
Made the text say it depends on class, and rest of explanation talk of lists, not objects.
1 parent 330cb60 commit c95ba00

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,11 +858,11 @@ a += [5, 6, 7, 8]
858858

859859
#### 💡 Explanation:
860860

861-
* a += b doesn't behave the same way as a = a + b
861+
* `a += b` doesn't always behave the same way as `a = a + b`. Classes *may* implement the op= operators differently, and lists do this.
862862

863-
* The expression `a = a + [5,6,7,8]` generates a new object and sets `a`'s reference to that new object, leaving `b` unchanged.
863+
* The expression `a = a + [5,6,7,8]` generates a new list and sets `a`'s reference to that new list, leaving `b` unchanged.
864864

865-
* The expression `a + =[5,6,7,8]` is actually mapped to an "extend" function that operates on the object such that `a` and `b` still point to the same object that has been modified in-place.
865+
* The expression `a + =[5,6,7,8]` is actually mapped to an "extend" function that operates on the list such that `a` and `b` still point to the same list that has been modified in-place.
866866

867867
---
868868

0 commit comments

Comments
 (0)