After the discussion in this thread I was wondering if there is in Julia 0.7 a way to get a NamedTuple starting from a
struct. For example:
julia> struct Person age::Float64 name::String end julia> p = Person(34, "Jane") Person(34.0, "Jane") julia> (;(v=>getfield(p, v) for v in fieldnames(typeof(p)))...) (age = 34.0, name = "Jane")
Is there a built-in function for this or is this the recommended way to go from a given
struct to NamedTuple? The application I have in mind is from the thread linked above: saving an Array of
struct in tabular format (as several columns) using NamedTuples (it would work very well with JuliaDB).