Consider
julia> nt = (;a = 10, b = 20)
(a = 10, b = 20)
julia> [(;k, v) for (k, v) in pairs(nt)]
2-element Vector{NamedTuple{(:k, :v), Tuple{Symbol, Int64}}}:
(k = :a, v = 10)
(k = :b, v = 20)
The above suggests that the keys of nt
are Symbol
s. The values of nt
are Int
s. Indeed,
julia> keys(nt)
(:a, :b)
julia> values(nt)
(10, 20)
When a collection is getindex
ed with value in the key space, it produces a value in the value space:
julia> nt[:a]
10
So far so good.
I do not see such consistency within the Pair
type itself.
julia> p = pairs(nt)
pairs(::NamedTuple) with 2 entries:
:a => 10
:b => 20
julia> [(;k, v) for (k, v) in pairs(p)]
2-element Vector{NamedTuple{(:k, :v), Tuple{Symbol, Int64}}}:
(k = :a, v = 10)
(k = :b, v = 20)
This suggests that the key space is Symbol
and the value space is Int
. However,
julia> keys(p)
(:a, :b)
julia> values(p) # hmm?
(a = 10, b = 20)
julia> p[:a]
10
Does the TODO in the definition of values(::Pairs)
refers to this issue?