Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
I take very detailed notes during these classes, but is anyone able explain this last point of the lecture. (See below)
••• WITH THE EXCEPTION OF THE +=, WE DON’T YOU THE EQUAL = SIGN IN THESE METHODS. ALL OF THESE METHODS CHANGE THE LISTS THEMSELVES. THE METHODS DID CREATE NEW VERSIONS OF THE LIST(S). THIS IS THE IMMUTABLE ASPECT OF LISTS.IT CAN COME BACK AN BITE YOU IF YOU ARE NOT CAREFUL.
I'm hoping this will become much clearer with examples in further lessons, but right now I'm not quite getting it.
Steven Parker228,978 Points
What is actually said (taken directly from the Video Transcript tab):
With the exception of the plus equals, I didn't use an equal sign in here at all. All of the methods just change the list itself. They didn't create new versions of the list. This is the mutable aspect of lists. And it can definitely come back to bite you if you're not careful with it.
He's just reminding you that the operations shown in the video make permanent changes to the original list, which is possible because of lists being mutable.
The importance may become more clear if you compare these with the methods of strings, which leave the original alone and return new versions with the changes applied.
So what might "bite" is if you got these confused, and performed an operation thinking the original value would be preserved but it got modified instead.