Updating nested structs in Elixir with put_in/2


Updating nested data in Elixir can be tough, since all data is immutable.

There’s a nice helper put_in/3 that works with maps. But unless structs implement the Access behaviour, we cannot use it with structs.

Turns out, there’s a put_in/2 macro that works with structs out of the box!

Want the latest Elixir Streams in your inbox?

    No spam. Unsubscribe any time.