If I define a function with kwargs...
, then I can use keys()
to get the names of whatever arguments were passed
julia> function printkeys(; kwargs...)
println(keys(kwargs))
end
printkeys (generic function with 1 method)
julia> printkeys(a=1, b=2)
(:a, :b)
but if I try and use values()
, I get a NamedTuple
julia> function printvalues(; kwargs...)
println(values(kwargs))
end
printvalues (generic function with 1 method)
julia> printvalues(a=1, b=2)
(a = 1, b = 2)
I’d actually have to call values()
again on the NamedTuple
to get what I originally expected
julia> function printvaluesvalues(; kwargs...)
println(values(values(kwargs)))
end
printvaluesvalues (generic function with 1 method)
julia> printvaluesvalues(a=1, b=2)
(1, 2)
I guess this just says that my expectations were wrong, but if I want a Tuple
(or possibly Vector
, or whatever) with just the values of the keyword arguments, is there a more idiomatic way to get it?