last for OrderedDict/KeyIterator/ValueIterator
oxinabox opened this issue · 1 comments
oxinabox commented
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
)