Updating nested structs 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!
Read next Webinar, Elixir/Phoenix Security: Preventing SQL Injection in Ecto