You can surelly initialise tuples with empty vectors and then modify them.
What you can’t do is reassign the tuple position/key to other objects or add/delete elements from the tuple, i.e. modify the tuple itself rather than one of its objects.
Unfortunately I do actually need to make things undefined, rather than just using empty vectors because I’m not just interested in arrays – the concrete example didn’t make that clear.
I really care about being able to put any arbitrary type in, and get whatever the usual undefined behaviour is for it.
Just to check, you are aware that if a Tuple started with an undefined field it would always have that field undefined, as it is immutable, correct? Is this yet useful to you?
Just to check, you are aware that if a Tuple started with an undefined field it would always have that field undefined, as it is immutable, correct? Is this yet useful to you?
Yes, and it is useful to me
(The use-case is that I need to be able to build a NamedTuple which has the same names and initialisation state as a given struct.)
struct Foo{T}
a::T
function Foo{T}() where {T}
new{T}()
end
end
julia> Foo{Float64}()
Foo{Float64}(2.7778122606e-314)
julia> Foo{Vector{Float64}}()
Foo{Vector{Float64}}(#undef)