In Julia, how does one initialize an array to store mutable structs? For example:
mutable struct Foo
func # Some function
end
function Bar(param1, param2)
function nestedFunc(param3)
return param3
end
return Foo(nestedFunc)
end
# Initializing with 0s will throw an error when
# I attempt to store the struct returned in the Bar call below
arr = zeros(5, 5)
for i in 1:5
for j in 1:5
arr[i, j] = Bar(i, j)
end
end
I've also tried to initialize an array of type Any, as arr = Array{Any, (5, 5)}, but again, when setting the index I get something like ERROR: LoadError: MethodError: no method matching setindex!
How can I do this, and what is the rationale for this behavior I'm seeing? In Python, I can arbitrarily initialize a list and set almost anything I want within a particular index.