julia> mydict = {"A"=>3, "B"=>5, "C"=>1}
{"B"=>5,"C"=>1,"A"=>3}
julia> mydict["B","C"]
ERROR: no method getindex(Dict{Any,Any},ASCIIString,ASCIIString)
But without getting an error? :)
Best Regards
-Leif
mydict[["A","B"]]
getindex(d::Dict, a::Array) = [d[i] for i=a]
julia> mydict = {"A"=>3, "B"=>5, "C"=>1}
{"B"=>5,"C"=>1,"A"=>3}
julia> import Base.getindex
julia> getindex(d::Dict, xs...) = [getindex(d, x) for x in xs]
getindex (generic function with 140 methods)
julia> mydict["B","C"]
2-element Array{Any,1}:
5
1
julia> import Base.getindex
julia> getindex(d::Dict, xs...) = [getindex(d, x) for x in xs]
getindex (generic function with 140 methods)
julia> mydict = {"A"=>3, "B"=>5, "C"=>1}
{"B"=>5,"C"=>1,"A"=>3}
julia> mydict[["B","C"]...]
2-element Array{Any,1}:
5
1
julia> c = ["B","C"];
julia> mydict[c...]
2-element Array{Any,1}:
5
1
import Base.getindex
getindex(d::Associative, xs...) = [getindex(d, x) for x in xs]
julia> import Base.getindex
julia> getindex(d::Dict, xs...) = [getindex(d, x) for x in xs]
getindex (generic function with 140 methods)
julia> mydict = {"A"=>3, "B"=>5, "C"=>1}
{"B"=>5,"C"=>1,"A"=>3}
julia> mydict[["B","C"]...]
2-element Array{Any,1}:
5
1
julia> c = ["B","C"];
julia> mydict[c...]
2-element Array{Any,1}:
5
1julia> mydict1 = {"A"=>3, "B"=>5, "C"=>1}{"B"=>5,"C"=>1,"A"=>3}
julia> typeof(mydict1)Dict{Any,Any} (constructor with 2 methods)
julia> mydict2 = ["A"=>3, "B"=>5, "C"=>1]["B"=>5,"C"=>1,"A"=>3]
julia> typeof(mydict2)Dict{ASCIIString,Int64} (constructor with 2 methods)
julia> mydict3 = (ASCIIString=>Int64)[]Dict{ASCIIString,Int64}()