How can I create a NamedTuple
with an abstract type?
When I try the following code, nt.a
is of concrete type Vector{Float64}
and the assignment nt.a[] = arr
fails because a Matrix{Int64}
cannot be converted to a Vector{Float64}
.
arr = zeros(Int, 2, 3)
nt = (a = Ref(Array{Float64, 1}()), b = 3) # I'd like to store AbstractArray instead of Vector{Float64}
nt.a[] = arr # MethodError: no method matching Vector{Float64}(::Matrix{Int64})
nt.a[][2, 2] = 100
arr[2, 2] == 100