Dict of NamedTuple

Hello ! :grinning:
I have a question about a behavior I don’t understand when I try to make a dictionary composed of NamedTuple. Each of these NamedTuple corresponds to a parameter set of a simulation.
For example:

julia> d = Dict( "param1" => (a = 1, b = 2))
Dict{String, @NamedTuple{a::Int64, b::Int64}} with 1 entry:
  "param1" => (a = 1, b = 2)

julia> d.keys
16-element Vector{String}:
    "param1"
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef
 #undef

I specify that I’m using Julia 1.10.2

Thanks !
fdekerm

this is an internal field of Dict, you shouldn’t be using it, you should use keys(d)

use keys(d) not d.keys and values(d) not d.values

:no_mouth: :no_mouth: :no_mouth:

My bad, I’ve been spending too much time on Python lately. Sorry for the question …

1 Like

no worries

2 Likes