Redefine Struct when working with REPL

Personally I’ve found that my structures don’t change too often, mostly it’s the code that is changing, so when I’ve (rarely) needed to change the structures I just do a stop/start of Julia inside atom.

If your structures are changing often then you can place them in a module like:

module Data
    struct Lion
        maneColor::String
        roar::String
        weight::Int # Do some work and then realize I need this attribute
    end
end

When you rerun the script you will get a warning that Data was redefined, which you can ignore. However Data.Lion will now be the new data object.

10 Likes