Set struct's parameters using a function whose first argument is for the struct

For a generic solution for changing immutables (and also mutables), I highly recommend Setfield.jl. It is useful, especially for nested immutables. You don’t need to understand anything complex for just using it, but if you want to know the idea behind Setfield.jl, this JuliaCon talk is a great introduction:

2 Likes