Skip to content

Returned Dictionaries.Dictonary type does not adhere to Julia Dict interface #57

@kmacdough

Description

@kmacdough

I was expecting to be able to iterate through these grouped dictionaries, but I'm noticing they do not seem to follow the AbstractDict interface. Is this an intentional design decision? If so, is there a benefit to this counterintuitive behavior?

julia> group(iseven, 1:5)
2-element Dictionaries.Dictionary{Bool, Vector{Int64}}
 false │ [1, 3, 5]
  true │ [2, 4]

julia> Dict(false => [1, 3, 5], true => [2, 4])
Dict{Bool, Vector{Int64}} with 2 entries:
  0 => [1, 3, 5]
  1 => [2, 4]

julia> collect(group(iseven, 1:5))
2-element Vector{Vector{Int64}}:
 [1, 3, 5]
 [2, 4]

julia> collect(Dict(false => [1, 3, 5], true => [2, 4]))
2-element Vector{Pair{Bool, Vector{Int64}}}:
 0 => [1, 3, 5]
 1 => [2, 4]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions