How do I get the subtype of an instance of an parametric type in julia? For example:
immutable Dog{T <: Number}
snout::T
end
dog = Dog(5.)
typeof(dog)
...returns Dog{Float64}
. Is there a way to get at the type Float64
from the variable dog
without referring explicitly to the field snout
?
abstract MyAbstractType
. Your typeDog
appears to be parametric, immutable, and composite, but not abstract. – Shortlyfieldtype(dog, 1)
orfieldtype(dog, :snout)
. I don't know of a method to return the type parameter of an instance of a parametric type (although it is possible that an undocumented one exists). – Shortly