The Problem With Mutable Objects: Accidental Modification

Let’s look at the problem of passing mutable objects to a function and learn how we can solve it.

Passing mutable objects to functions

The basic problem with mutable objects is this: if you pass a mutable object into a function, you have no way of guaranteeing that the function won’t change the object. For example:

Get hands-on with 1400+ tech skills courses.