Field names and values of a struct defined as NTuple

The struct have one field, and if you check the constructor (with e.g. methods(ex2)) you see that it expects one argument – the tuple. You are passing 4 arguments. If you pass a tuple it works (and the Ints are converted to UInt8s, since the default constructor converts):

julia> struct ex2
           data::NTuple{4, UInt8}
       end

julia> a = ex2((1, 2, 3, 4)) # one argument, the tuple (1, 2, 3, 4)
ex2((0x01, 0x02, 0x03, 0x04))

You extract the tuple with .data, then use getindex:

julia> a.data[1]
0x01

julia> a.data[3]
0x03
4 Likes