Inherit from a concrete type

You can only create Vector{Union{}} with undef, and from then on the exception will be accessing #undef elements, not specifically having anything to do with Union{}. Eg

julia> a = Vector{Union{}}(undef, 4)
4-element Vector{Union{}}:
 #undef
 #undef
 #undef
 #undef

julia> a[2]
ERROR: UndefRefError: access to undefined reference

which would be the same error for Vector{Any}(undef, ...) or any other abstract type.

1 Like