Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
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 Parker221,450 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.