There is the parameters field of the types, but I'm not sure if that's
considered private. You can do
Array{Float64, 1}.parameters[2]
to get 1, for example.
On Monday, February 15, 2016 at 2:14:35 PM UTC+1, jw3126 wrote:
>
> I have an instance of a parametric type, is there a canonical way to get
> the parameter values?
> For example I could have some Array{T, d} and want to know whether T is
> Float64 and what its dimension is.
> The only way of doing this I am aware of is writing code like:
>
> dimension{T, dim}(arr::Array{T, dim}) = dim
> numbertype{T, dim}(arr::Array{T, dim}) = T
>
> Is there a built-in function to do this? And maybe a way to get parameter
> values for arbitrary types?
> E.g. I have some instance of MyType{S, T, U, n} is and want to know U. Do
> I have to repeat code like the above each time I define a new parametric
> type?
>