Saturday 2 April 2016

Julia: Get sub types of given type


subtypes(T): Return a list of immediate subtypes of DataType T.
julia> subtypes(Number)
2-element Array{Any,1}:
 Complex{T<:Real}
 Real            

julia> subtypes(Real)
4-element Array{Any,1}:
 AbstractFloat       
 Integer             
 Irrational{sym}     
 Rational{T<:Integer}

julia> subtypes(Integer)
4-element Array{Any,1}:
 BigInt  
 Bool    
 Signed  
 Unsigned

julia> subtypes(Bool)
0-element Array{Any,1}

julia> subtypes(BigInt)
0-element Array{Any,1}

Note
Any is the super type for all data types in Julia.


Previous                                                 Next                                                 Home

No comments:

Post a Comment