isleaftype
isleaftype(T)
Determine whether T is a concrete type that can have instances, meaning its only subtypes are itself and None (but T itself is not None).
Examples
# Check if a type is a concrete leaf type
julia> isleaftype(Int)
true
julia> isleaftype(Array{Float64, 2})
true
julia> isleaftype(Any)
false
julia> isleaftype(Union{Int, String})
false
julia> isleaftype(Nothing)
false
In the above examples:
Intis a concrete leaf type because it does not have any subtypes other than itself.Array{Float64, 2}is also a concrete leaf type because it only has itself as a subtype.Anyis not a concrete leaf type because it has multiple subtypes.Union{Int, String}is not a concrete leaf type because it has subtypes other than itself.Nothingis not a concrete leaf type because it is a singleton type and not a concrete type that can have instances.
The isleaftype function is useful for checking if a type is a concrete leaf type, meaning it can have instances and does not have any subtypes other than itself and None.
See Also
BigFloat, BigInt, Dict, eltype, fieldtype, Float32, Float64, IntSet, isa, isalnum, isalpha, isascii, iseltype, isequal, isgraph, isimmutable, isinteractive, isleaftype, isnull, ispunct, isspace, issubtype, keytype, Nullable, NullException, promote_type, typeintersect, typejoin, typemax, typemin, typeof, Val, valtype,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.