Hello everybody, i was playing with dictionary … i can’t understand why the last my statement is not correct in this case:
println("1° dictionary")
myDictionary1 = Dict()
push!(myDictionary1,"alpha"=>[10,20]) # ok this works, using push
println("2° dictionary")
myDictionary2 = Dict{String,Vector{Int64}}
myDictionary2("betha"=>[1,2,3,4,5]) # another possible way to add to dictionary
println("2° dictionary using push")
push!(myDictionary2,"alpha"=>[10,20]) # why this gives an error???
I was trying to be more precise in type definition of my Dict, and i tried to transform Dict() in Dict{String,Vector{Int64}}, but, surprisingly, Julia tell me that the last line is not correct, also if in the exact sintex i used in the first dictionary. The error is:
ERROR: LoadError: MethodError: no method matching push!(::Type{Dict{String,Array{Int64,1}}}, ::Pair{String,Array{Int64,1}})
Closest candidates are:
push!(::Any, ::Any, ::Any) at abstractarray.jl:2159
push!(::Any, ::Any, ::Any, ::Any...) at abstractarray.jl:2160
push!(::Array{Any,1}, ::Any) at array.jl:875
...
Stacktrace:
[1] top-level scope at C:\vmswap\juliaPrj\querere\example01.jl:9
in expression starting at C:\vmswap\juliaPrj\querere\example01.jl:9
Thanks for help! i really don’t understand …