Вы можете создавать конструкторы по умолчанию, которые просто помещают пустые объекты для всех полей, которые вы можете обновить позже, например
julia> struct Bands
B0::String
B1::String
# Create a constructor that puts an empty String ("") for each field
Bands() = new(("" for _ in 1:length(fieldnames(Bands)))...)
# Define a vararg constructor
Bands(args...) = new(args...)
end
julia> struct Masks
mask1::Bands
mask2::Bands
# Create a constructor that puts an empty Bands (Bands()) for each field
Masks() = new((Bands() for _ in 1:length(fieldnames(Masks)))...)
# Define a vararg constructor
Masks(args...) = new(args...)
end
julia> masks = Masks()
Masks(Bands("", ""), Bands("", ""))
julia> using Setfield
julia> masks = @set masks.mask1 = Bands("hello", "world") # Set a field of masks
Masks(Bands("hello", "world"), Bands("", ""))
julia> masks = @set masks.mask2.B0 = "hello" # Set a field of masks.mask2
Masks(Bands("hello", "world"), Bands("hello", ""))