Stream: helpdesk (published)

Topic: Automatic Update of Struct


view this post on Zulip Davi Sales Barreira (Nov 28 2021 at 13:50):

Is there a "proper" way in Julia to create a struct that runs an "updating function" whenever one of it's attributes changes? For example:

mutable struct Example
 name::String
 past_names
end

Now, whenever the name attribute changes, the past_name should append the past name.

view this post on Zulip Sukera (Nov 28 2021 at 14:07):

you can highjack setproperty!

view this post on Zulip Sukera (Nov 28 2021 at 14:07):

note that this sort of spook action at a distance can lead to very hard to maintain code


Last updated: Oct 02 2023 at 04:34 UTC