You can use merge
. If the Dict
s have elements with the same key, the value for that key will be of the last Dict
listed.
If you want to combine the elements of the Dict
s that have the same key, you can use mergewith(combine, collection, others...)
. combine
is a function that receive two values and return a value. See mergewith
.
Example of the docs:
julia> a = Dict("foo" => 0.0, "bar" => 42.0)
Dict{String,Float64} with 2 entries:
"bar" => 42.0
"foo" => 0.0
julia> b = Dict("baz" => 17, "bar" => 4711)
Dict{String,Int64} with 2 entries:
"bar" => 4711
"baz" => 17
julia> mergewith(+, a, b)
Dict{String,Float64} with 3 entries:
"bar" => 4753.0
"baz" => 17.0
"foo" => 0.0