Bardo
1
From a stream, I receive a number of arrays and strings as their field names.
How can I dynamically build a structure from it?
Of course, trying to define a struct within the code generates
ERROR: LoadError: syntax: “struct” expression not at top level
You can’t declare structs on the fly like that. They are a part of the global state. But you can create nested Dict
s or NamedTuple
s.
2 Likes
Bardo
3
julia> ntup2 = (a = 1, b = 2)
(a = 1, b = 2)
julia> ntup2.b
2
Excellent, thx!
Bardo
4