Lesson 24. Mutable and immutable objects
After reading lesson 24, you’ll be able to
- Understand what an immutable object is
- Understand what a mutable object is
- Understand how objects are stored in computer memory
Consider the following scenario. You buy a house that’s just the right size for you; it’s big enough for one person to live in. Then you get married, and there’s no space for your spouse. You have two choices: build an addition to the house, or tear the whole house down and build a new larger house to hold two people. Building an addition makes more sense than demolishing a perfectly good house and making an exact copy of it just to make an addition. Now, you have a kid and decide you need more room. Again, do you build an addition ...
Get Get Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.