Get all object field values as tuple

Hellow!

how can i get all object field values as tuple better as this:

object_field_values = (getproperty.(repeat([object],fieldcount(T)), fieldnames(T))...,)

Try

ntuple(fieldcount(T)) do i
    getfield(x, i)
end

Where x is the instance and T = typeof(x)
I’m on my phone and haven’t tried it, but I think it should do the trick.

2 Likes

See Get fieldnames and values of `struct` as NamedTuple and also https://github.com/JeffreySarnoff/NamedTupleTools.jl#struct-construction-conversion