# Why doesn't an argument of Vector{Vector{T} where T\<:Real} accept a variable of Vector{Vector{Int64}}?

**URL:** <https://discourse.julialang.org/t/why-doesnt-an-argument-of-vector-vector-t-where-t-real-accept-a-variable-of-vector-vector-int64/10792>\
**Category:** New to Julia\
**Created:** [May 9, 2018, 5:30am UTC](https://discourse.julialang.org/t/why-doesnt-an-argument-of-vector-vector-t-where-t-real-accept-a-variable-of-vector-vector-int64/10792 "2018-05-09T05:30:54Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [May 9, 2018, 6:26am UTC](https://discourse.julialang.org/t/why-doesnt-an-argument-of-vector-vector-t-where-t-real-accept-a-variable-of-vector-vector-int64/10792/2 "2018-05-09T06:26:04Z")

</div>

Because your `a` is not a subtype of `Vector{Vector{<:Real}}` (which is a shorthand for what you write):

```julia
julia> a = Vector{Vector}(3);

julia> for i in 1:3
       a[i] = [i, i+ 1]
       end;

julia> a
3-element Array{Array{T,1} where T,1}:
 [1, 2]
 [2, 3]
 [3, 4]

```

However, this does not work either:

```julia
julia> a = Vector{Vector{Int}}(3);

julia> for i in 1:3
       a[i] = [i, i+ 1]
       end;

julia> a
3-element Array{Array{Int64,1},1}:
 [1, 2]
 [2, 3]
 [3, 4]

julia> f3(a)
ERROR: MethodError: no method matching f3(::Array{Array{Int64,1},1})
Closest candidates are:
  f3(::Array{Array{T,1} where T<:Real,1}) at REPL[1]:2

```

This finally works:

```julia
julia> a = Vector{Vector{<:Real}}(3);

julia> for i in 1:3
       a[i] = [i, i+ 1]
       end;

julia> a
3-element Array{Array{T,1} where T<:Real,1}:
 [1, 2]
 [2, 3]
 [3, 4]

julia> f3(a)
3-element Array{Array{Int64,1},1}:
 [2, 4]
 [4, 6]
 [6, 8]

```

However, what you probably wanted to do was:

```julia
function f3(a::Vector{Vector{T}}) where T<:Real
2a
end

```

then all of the above `a` will work. Search the docs or this forum for “invariance” to find enlightenment (although, it is a bit a tricky subject).

PS: please quote your code snippets using backticks `: [PSA: how to quote code with backticks](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530)

---

_[View the full topic](https://discourse.julialang.org/t/why-doesnt-an-argument-of-vector-vector-t-where-t-real-accept-a-variable-of-vector-vector-int64/10792)._
