I was working with Dict recently and found some strange behavior, i dont know if its meant to be this way, but i got curious about the reasoning(if intended).
julia> Dict{Symbol,Union{Missing,Any}}()
Dict{Symbol,Any} with 0 entries
julia> dict = Dict{Symbol,Union{Missing,Any}}()
Dict{Symbol,Any} with 0 entries
julia> push!(dict,:a => missing, :b => "string")
Dict{Symbol,Any} with 2 entries:
:a => missing
:b => "string"
Here i pass explicitly the type of the dict, and Julia returns Dict{Symbol, Any}
. As missing is a type too, converting to Any
would be ok. But here is where i think its inconsistent:
julia> Dict(:a => missing, :b => "string")
Dict{Symbol,Union{Missing, String}} with 2 entries:
:a => missing
:b => "string"
In this case, passing directly on the constructor, it’s built with the desired type.