Say I have a struct defined as ::GridStruct{::Integer, ::Integer, ::Number}, for example:
Grid = GridStruct(DomainSize, Cells, <irrelevant details>...)
println(typeof(Grid))
yields
GridStruct{3, Int64, Float64}
how can I "extract" (read/get) the inner types/values of (3, Int64, Float64) ?
I would want to be able to read this data for various uses, such as pre-determinind the dimensions (3 in this case) and the types for dispatch (Int64 and Float65 combination).
>Solution :
You can use some sneaky generic programming:
julia> struct A{T, U, V} end
julia> typeparams(::Type{A{T, U, V}}) where {T,U,V} = (T, U, V)
typeparams (generic function with 1 method)
julia> typeparams(A{3, Int64, Float64})
(3, Int64, Float64)