Returning Arrays from Functions - Recommended Approach?

I usually use a struct of arrays that I pass to every function as first parameter, because in this way it can be re-used for multiple calls to solve() and is allocated only once. You can see a complex example here: KiteModels.jl/KiteModels.jl at main · ufechner7/KiteModels.jl · GitHub line 107ff

I usually have functions like:
clear(state)
init(state)
solve(state)

As long as there are only arrays in the struct there is no need for a mutable struct, a simple (immutable) struct is good enough.

5 Likes