Is the way, how to get an array of values from the Dict by array of keys? the same way as DataFrames works.
For instance.
a=Dict(1=>"a",2="b",3=>"c")
a[[1,2]] gets ["a","b"]
thank you in advance.
Is the way, how to get an array of values from the Dict by array of keys? the same way as DataFrames works.
For instance.
a=Dict(1=>"a",2="b",3=>"c")
a[[1,2]] gets ["a","b"]
thank you in advance.
D=Dict(:a=>"a",:b=>"b",:c=>"c")
getindex.(Ref(D),[:a,:b])
map(x->D[x], [1,2])
or [D[x] for x in [1,2]]
is how I’d do it. If you really want to use the syntax you showed, you could do something like (the following is not tested)
Base.getindex(d::AbstractDict, inds::Vector) = [d[x] for x in inds]
But (1) don’t put that into code that other people might load (eg a package) - it’s type piracy - and (2) I don’t know if that will break something else.