It makes the code icky and hard to debug, and you can simply return new immutable objects for every state change.

EDIT: why not just create a new object and reassign variable to point to the new object

  • @[email protected]
    link
    fedilink
    1124 hours ago

    multiple other objects might be holding a reference to the object you want to change, so you’d either have to recreate those too or mutate them to let them point to the new object.

    however if you can do what you want to do in a side effect free way i suggest doing that, as it is indeed easier to reason about what happens this way.