# Type inference on an array of arrays

**URL:** <https://discourse.julialang.org/t/type-inference-on-an-array-of-arrays/29439>\
**Category:** New to Julia\
**Created:** [October 3, 2019, 9:58am UTC](https://discourse.julialang.org/t/type-inference-on-an-array-of-arrays/29439 "2019-10-03T09:58:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HenrikM](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrikm/32/17975_2.png) [@HenrikM](https://discourse.julialang.org/u/HenrikM)\
**Post date:** [October 3, 2019, 9:58am UTC](https://discourse.julialang.org/t/type-inference-on-an-array-of-arrays/29439/1 "2019-10-03T09:58:30Z")

</div>

Hello, could you please help me to understand the following code. I think the types line up really nicely, but Julia 1.2 thinks otherwise.

```julia-auto
d = 2
a1 = [0.0]
a2 = [0.0]
b1 = zeros(d, 1)
b2 = zeros(d, 1)
c1 = [0.0]
c2 = [0.0]

function test1(a::AbstractVector{AbstractVector{T}},
               b::AbstractVector{AbstractMatrix{T}},
               c::AbstractVector{AbstractVector{T}}
               ) where T <: AbstractFloat
    return "Done!"
end

```

This seems fine:

```julia-auto
methods(test1)

```

# 1 method for generic function “test1”:

[1] test1(a::AbstractArray{AbstractArray{T,1},1}, b::AbstractArray{AbstractArray{T,2},1}, c::AbstractArray{AbstractArray{T,1},1}) where T\<:AbstractFloat in Main at typeerror.jl:13

But this fails:

```julia-auto
test1([a1, a2], [b1, b2], [c1, c2])

```

**ERROR:** MethodError: no method matching test1(::Array{Array{Float64,1},1}, ::Array{Array{Float64,2},1}, ::Array{Array{Float64,1},1})

Stacktrace:

[1] top-level scope at **REPL[3]:1**

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 3, 2019, 10:00am UTC](https://discourse.julialang.org/t/type-inference-on-an-array-of-arrays/29439/2 "2019-10-03T10:00:46Z")

</div>

Have you read through this part in the manual [Types · The Julia Language](https://docs.julialang.org/en/v1/manual/types/index.html#Parametric-Composite-Types-1)? Especially the point about

> This last point is _very_ important: even though `Float64 <: Real` we **DO NOT** have `Point{Float64} <: Point{Real}` .

---

<div class="post-metadata">

**Author:** ![HenrikM](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrikm/32/17975_2.png) [@HenrikM](https://discourse.julialang.org/u/HenrikM)\
**Post date:** [October 3, 2019, 11:57am UTC](https://discourse.julialang.org/t/type-inference-on-an-array-of-arrays/29439/3 "2019-10-03T11:57:56Z")

</div>

OK, I was not paying attention. Thank you!

TL;DR:

```julia
function test1(a::AbstractVector{TV},
               b::AbstractVector{TM},
               c::AbstractVector{TV}
               ) where {TV <: AbstractVector{T}, TM <: AbstractMatrix{T}} where T <: AbstractFloat
    return "Done!"
end

```
