I was surprised by this:
function test(;args...)
for k in keys(args)
pop!(args,k,nothing)
end
end
When called as test(z=1)
, this error results:
ERROR: MethodError: no method matching pop!(::Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol},NamedTuple{(:z,),Tuple{Int64}}}, ::Symbol, ::Nothing)
Since the type of args
is Base.Iterators.Pairs <: AbstractDict
, I expected pop!
to work. Other “dictionary-type” functions such as keys
work fine. Is this missing functionality, or is my expectation wrong?
Is there a function that provides similar functionality to pop!
for key-value iterators over named tuples?