-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
@iamed2 pointed this out in #59, here. We do not have consistency between the pop!
function for LittleDict
and OrderedDict
.
LittleDict
Will return nothing
if the key is not found.
OrderedCollections.jl/src/little_dict.jl
Lines 239 to 251 in 5fb23d8
function Base.pop!(dd::UnfrozenLittleDict, key) | |
@assert length(dd.keys) == length(dd.vals) | |
for ii in 1:length(dd.keys) | |
cand = @inbounds dd.keys[ii] | |
if isequal(cand, key) | |
deleteat!(dd.keys, ii) | |
val = @inbounds dd.vals[ii] | |
deleteat!(dd.vals, ii) | |
return val | |
end | |
end | |
end |
OrderedDict
Will throw a KeyError
if the key is not found.
OrderedCollections.jl/src/ordered_dict.jl
Lines 380 to 383 in 5fb23d8
function pop!(h::OrderedDict, key) | |
index = ht_keyindex(h, key, false) | |
index > 0 ? _pop!(h, index) : throw(KeyError(key)) | |
end |
I propose that we make the following changes:
- Have
LittleDict
throw aKeyError
when the key is not found. - Introduce a new function which provides a
default
value to return if key DNE (LittleDict pop! default #59)
schneiderfelipe and PyDataBlog
Metadata
Metadata
Assignees
Labels
No labels