Extracing tuple types

Given a tuple, how do I extract the type parameters information? It seems that I can do the following but I’m wondering if there’s a better way i.e. using a public API rather than accessing the types or parameters field (which seems “private” to me). Similar post from 1.5 years ago.

julia> x = (1, 2, "a", 'c')
(1, 2, "a", 'c')

julia> tx = typeof(x)
Tuple{Int64,Int64,String,Char}

julia> tx.types
svec(Int64, Int64, String, Char)

julia> tx.parameters
svec(Int64, Int64, String, Char)
julia> fieldtypes(typeof(x))
(Int64, Int64, String, Char)
2 Likes

This is perfect but I’m curious how you figured this out? I tried to find the right function using methodswith but did not see anything like this.

I was missing this functionality (as you noted in the topic you linked), so I made the PR :wink:

If you think the discoverability of this is lacking and could be improved, perhaps you should make a PR.

1 Like

Haha… :smile: That’s great! Thanks a lot for your contribution!