Skip to content

DefaultDict and haskey #630

@goretkin

Description

@goretkin

I didn't find a conversation around whether haskey should always return true for DefaultDict.

julia> using DataStructures: DefaultDict

julia> d1 = DefaultDict(0, :A=>1, :B=>2)
DefaultDict{Symbol,Int64,Int64} with 2 entries:
  :A => 1
  :B => 2

julia> haskey(d1, :C)
false

julia> d1[:C]
0

This would make it inconsistent with keys, but consistent with getindex.

Metadata

Metadata

Assignees

No one assigned

    Labels

    requires thoughtFor things that need some thought in them and do not have obvious correct answer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions