Yeah, the exact same definition is right there <https://github.com/JuliaLang/julia/blob/8e1d8ba2b3938dfacee6fc3a3c332e37df52b5de/base/dict.jl#L176-L184>. Odd that I missed it, maybe it's new?
Anyway, looks like that will do what you want, Ben. On 27 July 2014 13:41, Tomek Trzeciak <[email protected]> wrote: > Isn't merge! already in the standard library? > > > On Sunday, July 27, 2014 11:24:36 AM UTC+1, Mike Innes wrote: > >> Just in case it's useful here's a function which I use: >> >> function merge!(a::Dict, b::Dict) >> for (k, v) in b >> a[k] = v >> end >> return a >> end >> >> If you replace push! with merge! in your original example it should work >> as expected. >> >> >> On 27 July 2014 01:11, John Myles White <[email protected]> wrote: >> >>> You don’t push to Dict’s because they’re not ordered. >>> >>> You can add a entry using indexing: >>> >>> dc = Dict{UTF8String, Int64}() >>> dc["A."] = 2 >>> >>> — John >>> >>> On Jul 26, 2014, at 5:09 PM, Ben Ward <[email protected]> wrote: >>> >>> Is it possible to extend a dict with a key value pair? >>> >>> I don't see a method to do it in the standard library reference. There >>> is a pop!, but I tried push! but it just produced an error. Perhaps I'm not >>> doing it right. >>> >>> dc = Dict{String, Int64}() >>> push!(dc, ["A." => 2]) >>> >>> >>> *Thanks,* >>> >>> *Ben.* >>> >>> >>> >>
