Finding the type used to contruct a parameterized type

Suppose I have a type definition like

type MyType{T}
    x::Vector{T}
end

Now say I have a variable of type MyType, but I don’t know what tye is used as T for it.
How can I get the dataype T?
I can’t do typeof(variable_name.x[1]), as x may be empty?
When I do typeof(var_name.x), I gets back something like Array{Char,1}. But how to get the Char alone?

Let the dispatch tell you

f(::MyType{T}) where T = T

1 Like

This is cool.
Thanks :slight_smile: