O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Cases for mutability

Whenever we require to change an immutable object, we will need to create a new, modified copy of it. This might not be costly and tedious for small and simple objects, but will be in cases where we have large or complex objects with lots of properties and operations.

Also, changing an existing object is simpler and much more intuitive than creating a new, modified copy of it for objects with a distinct identity, for instance, a profile of a user. We may want to maintain a single object of a user's profile and modify it when necessary. This might not be a great example as it is hard to see the performance penalty for this case, but the speed of execution can be a very important differentiator for some types of application, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required