DataStructures.jl icon indicating copy to clipboard operation
DataStructures.jl copied to clipboard

Is it intentional that setindex! does not work on MultiDict

Open ndinsmore opened this issue 6 years ago • 1 comments

Right now setindex! does not work on MultiDict which also means dict[1]=1 does not work. Is that intentional?

ndinsmore avatar Apr 10 '19 19:04 ndinsmore

This looks like a bug to me. One should be able to write

multidict[1] = [1]

currently I don't see how to create a multidict with an empty list without monkey-patching

julia> md = MultiDict{Symbol, Int}()
julia> insert!(md, :a, 1)
julia> md.d[:b] = Int[] # monkey-patch
julia> md
MultiDict{Symbol, Int64}(Dict(:a => [1], :b => []))
julia> for (key, values) in md
   for value in values
        println(key, ' ', value)
    end
end   
a 1

davidavdav avatar Sep 22 '22 15:09 davidavdav