Understaing vector (or array?) fields in julia mutable struct

I tried to make minimal changes to get the script working:

mutable struct S3_str
    c::Int64
    d::Float64
    S3_str() = new(0,0.)
end
mutable struct S2_str
  a::Int64
  b::Array{Int64,1}
  s3::Vector{S3_str} #I would like to have a vector field of s3 structures here
  S2_str() = new(0, [0], S3_str[]) 
end
mutable struct S1
s2::Vector{S2_str} #I would like to have a vector field of s2 structures here
S1() = new(S2_str[]) 
end

s1 = S1()
push!(s1.s2, S2_str())
s1.s2[1].b = Int[1, 2, 3]
push!(s1.s2[1].s3, S3_str())
s1.s2[1].s3[1].c = 4
@show s1

yielding

s1 = S1(S2_str[S2_str(0, [1, 2, 3], S3_str[S3_str(4, 0.0)])])
2 Likes