julia> struct Foo
bar
baz::Int
qux::Float64
end
julia> foo = Foo(1,2,3)
Foo(1, 2, 3.0)
julia> fieldnames(foo)
ERROR: MethodError: no method matching fieldnames(::Foo)
Closest candidates are:
fieldnames(::Core.TypeofBottom)
@ Base reflection.jl:190
fieldnames(::Type{<:Tuple})
@ Base reflection.jl:192
fieldnames(::DataType)
@ Base reflection.jl:187
...
Stacktrace:
[1] top-level scope
@ REPL[12]:1
This example is from the julia docs,
https://web.mit.edu/julia_v0.6.2/julia/share/doc/julia/html/en/manual/types.html#Composite-Types-1
It does not work as the doc states.
In my computer, the following works:
julia> fieldnames(Foo)
(:bar, :baz, :qux)