Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

last for OrderedDict/KeyIterator/ValueIterator #99

Closed
oxinabox opened this issue Mar 15, 2023 · 1 comment
Closed

last for OrderedDict/KeyIterator/ValueIterator #99

oxinabox opened this issue Mar 15, 2023 · 1 comment
Labels
good first issue Good for newcomers

Comments

@oxinabox
Copy link
Member

first works on all of these, but last doesn't

julia> dd =  OrderedDict(1=>2, 3=>4)
OrderedDict{Int64, Int64} with 2 entries:
  1 => 2
  3 => 4

julia> first(dd)
1 => 2

julia> last(dd)
ERROR: MethodError: no method matching lastindex(::OrderedDict{Int64, Int64})
...

But you can get them via:

julia> last(dd.keys)
3

julia> last(dd.vals)
4

But that is going in to the internals.

This should be a nice easy PR.
Just need to dispatch on Base.ValueIterator{OrderedDict{<:Any, <:Any}} (similar for the KeysIterator) and look at the backing dict, and then look at it's dict.vals (similarly dict.keys)

@oxinabox oxinabox added the good first issue Good for newcomers label Mar 15, 2023
@pri1311
Copy link
Contributor

pri1311 commented Aug 4, 2023

Surprising! I have previously added a PR for the same - #94 also works locally for me
Screenshot 2023-08-05 at 12 53 52 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants