Guru's Verification engine ensures consistency, confidence, and trust in the knowledge your organization shares. Learn more.

Julia | How to update immutable objects

It is often beneficial to have some data be immutable, so that any code that is manipulating that data is easier to reason with. However, sometimes it becomes necessary to update that data, in which case it can be cumbersome to have to make a copy each time.

In Julia, an easier way to make updates is to use the Setfield package [1], which enables the following grammar:

using Setfield@set some_immutable_object.a.b.c = d

Resources:

You must have Author or Collection Owner permission to create Guru Cards. Contact your team's Guru admins to use this template.