Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Broadcast [possibly missing] key value pairs from one Dict to another?

$
0
0

How can I broadcast key value pairs from one Dict to another, whether or not they exist?

Tried the following but it doesn’t work:

check = Dict()
check2 = Dict(:a=>1,:b=>"b")
check[keys(check2).=values(check2)]
@test get(check,:a,"") == 1 && get(check,:b,"") == "b"

ERROR: KeyError: key Pair{Symbol,B} where B[:a => 1, :b => "b"] not found
Stacktrace:
 [1] getindex(::Dict{Any,Any}, ::Array{Pair{Symbol,B} where B,1}) at ./dict.jl:467
 [2] top-level scope at /home/au/code/BioPAXwork/local/pcquery/Ex_annotate_seurat.jl:71

Broadcasting seems readable and efficient by if there is a better way to update one Dict with another that’s great too.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles