Base.return_types

question
#1

Why Base.return_types returns an array instead of a single type?

julia> Base.return_types(sqrt, (Float16,))
1-element Array{Any,1}:
Float16
0 Likes

#2
> methods(sqrt, (AbstractFloat,))
# 4 methods for generic function "sqrt":
[1] sqrt(a::Float16) in Base.Math at math.jl:1018
[2] sqrt(x::BigFloat) in Base.MPFR at mpfr.jl:573
[3] sqrt(x::Union{Float32, Float64}) in Base.Math at math.jl:492
[4] sqrt(x::Real) in Base.Math at math.jl:518

> Base.return_types(sqrt, (AbstractFloat,))
4-element Array{Any,1}:
 Float16
 BigFloat
 Union{Float32, Float64}
 Union{Float16, Float32, Float64, BigFloat}
2 Likes