Error: Cannot 'Convert' an object of type Array{Float64,3} to an object of type float64

It looks like you are supplying fields to Results in the wrong order. When you do res = Results(pol_func, val_func, lab_func, age_j, mu, r, w, b, K, L), the first argument, pol_func is of type Array{Float64, 3}. However, when you set up your Results struct, you defined the first field to have type Float64.

To solve, simply change the order of the arguments in the res = Results line.

Lastly, as purely a stylistic note… Are you sure you need the type parameters for the fields in your struct? When people start with Julia, a common frustration is putting types on everything, then running into MethodErrors because the Julia type tree is large and there can be many corner cases that aren’t initially intuitive.

1 Like