Hi !
I have a question about mutable structs. I have a model model composed of several compartments, each characterized by (say) 2 values a and b. I would like to make a for loop to test different values of a and b for these buckets. The following code does not work because "type Model has no field compartment". Is this normal behavior, and if so 1) why? and 2) how to do otherwise?

Thanks !

mutable struct Compartment
a::Int64
b::Float64
end
Base.@kwdef mutable struct Model
compartment1::Compartment
compartment2::Compartment
compartment_list::Vector{Compartment} = [compartment1, compartment2]
end
c1 = Compartment(2, 16.0)
c2 = Compartment(5, 67.0)
model = Model(compartment1 = c1, compartment2 = c2)
for compartment in model.compartment_list
model.compartment.a +=1
model.compartment.b += 6.3
end

julia> Base.iterate(m::Model, n=1) = if n ≤ fieldcount(Model); getfield(m, n), n+1 end
julia> for comp in model
comp.a += 1
comp.b += 6.3
end
julia> c1
Compartment(3, 22.3)
julia> c2
Compartment(6, 73.3)