# Return types of function is Any\[Float64\], although I defined return type to be Float64

**URL:** <https://discourse.julialang.org/t/return-types-of-function-is-any-float64-although-i-defined-return-type-to-be-float64/106438>\
**Category:** New to Julia\
**Tags:** parametric-types, function, type-stability\
**Created:** [November 19, 2023, 2:28pm UTC](https://discourse.julialang.org/t/return-types-of-function-is-any-float64-although-i-defined-return-type-to-be-float64/106438 "2023-11-19T14:28:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zarkoivkovic](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zarkoivkovic/32/204042_2.png) [@zarkoivkovic](https://discourse.julialang.org/u/zarkoivkovic)\
**Post date:** [November 19, 2023, 2:28pm UTC](https://discourse.julialang.org/t/return-types-of-function-is-any-float64-although-i-defined-return-type-to-be-float64/106438/1 "2023-11-19T14:28:37Z")

</div>

Hello everyone,  
I have a function whose return type is defined and it’s Float64. However, when I check with Base.return\_types(f), it says Any[Float64]. What does it mean and will it affect performance?

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [November 19, 2023, 2:32pm UTC](https://discourse.julialang.org/t/return-types-of-function-is-any-float64-although-i-defined-return-type-to-be-float64/106438/2 "2023-11-19T14:32:20Z")

</div>

That’s good, it just means the only return type is `Float64`. From the docstring:

> Return a list of possible return types for a given function `f` and argument types `types`.  
> The list corresponds to the results of type inference on all the possible method match  
> candidates for `f` and `types` (see also [`methods(f, types)`](@ref methods).

So if you give abstract types to match more methods, you’d see a larger array of types inferred from the types you provided or the argument annotations, depending on which is more specific:

```julia
julia> f(x::Any) = x+1; f(x::Float64) = x-0.1
f (generic function with 2 methods)

julia> Base.return_types(f, (Int,)) # infers f(::Int) for f(x::Any)
1-element Vector{Any}:
 Int64

julia> Base.return_types(f, (Number,)) # f(::Number) for f(x::Any), f(::Float64) for f(x::Float64)
2-element Vector{Any}:
 Float64
 Any

```

Just use `@code_warntype` or packages like JET.jl and Cthulhu.jl for a particular call signature, it’s more informative.

---

<div class="post-metadata">

**Author:** ![zarkoivkovic](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zarkoivkovic/32/204042_2.png) [@zarkoivkovic](https://discourse.julialang.org/u/zarkoivkovic)\
**Post date:** [November 19, 2023, 2:35pm UTC](https://discourse.julialang.org/t/return-types-of-function-is-any-float64-although-i-defined-return-type-to-be-float64/106438/3 "2023-11-19T14:35:02Z")

</div>

Thank you so much, I got confused because of Any. But now I see it refers to type of elements in the list, and I have only Float64 in the list.  
Thank you for a fast reply!
