How define this Dict more precise?

I can’t understand why … :-/
What is wrong in defining a dictionary in a more precise way?

julia> x = Dict()
Dict{Any,Any} with 0 entries

julia> x["weight"]=105
105

julia> x["number"]=3
3

julia> x
Dict{Any,Any} with 2 entries:
  "weight" => 105
  "number" => 3

julia> y = Dict{String,Int64}
Dict{String,Int64}

julia> y["weight"]=105
ERROR: MethodError: no method matching setindex!(::Type{Dict{String,Int64}}, ::Int64, ::String)
Stacktrace:
 [1] top-level scope at REPL[55]:1

julia>

This doesn’t create a dict, but assigns the type to y. Instead, use y = Dict{String,Int64}()

8 Likes

Ah, thank you very much.
Dario