Build struct from arrays and names

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 Dicts or NamedTuples.

2 Likes
julia> ntup2 = (a = 1, b = 2)
(a = 1, b = 2)

julia> ntup2.b
2

Excellent, thx!

Follow-up thread: Reshape into named tuple - General Usage - JuliaLang