Skip to content

Is push! implemented correctly? #118

Open
@torfjelde

Description

@torfjelde

I just recently discovered that push! is implemented for Dict and it states the following in the docstring:

Because of this I sort of (maybe naively) expected push!(::OrderedDict, ::Pair) to always insert entries at the end, but this doesn't seem to be the case:

julia> using OrderedCollections

julia> d = OrderedDict(:x => 1)
OrderedDict{Symbol, Int64} with 1 entry:
  :x => 1

julia> push!(d, :y => 2)
OrderedDict{Symbol, Int64} with 2 entries:
  :x => 1
  :y => 2

julia> push!(d, :x => 3)  # Expected `:x => 3` to be after `:y => 2` here
OrderedDict{Symbol, Int64} with 2 entries:
  :x => 3
  :y => 2

Is this intentional?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions