Hello, I have defined an object via a mutable struct and I would like to instantiate n of them into a vector. Ultimately, I’d like to refer two them as vector[i].
Here’s MWE:
mutable struct Foo
x :: Float64
y :: Float64
endfoos = Vector{Foo}
n = 3
for i in 1:3
foo = Foo(randn(), 0)
push!(foos, foo)
end
I’d like to reference x in the second foo instance as
foos[2].x
Thanks for looking!