# Error caused by Sending Vector{Int64} to Vector{Integer} type function

**URL:** <https://discourse.julialang.org/t/error-caused-by-sending-vector-int64-to-vector-integer-type-function/83194>\
**Category:** General Usage\
**Tags:** question\
**Created:** [June 22, 2022, 5:28pm UTC](https://discourse.julialang.org/t/error-caused-by-sending-vector-int64-to-vector-integer-type-function/83194 "2022-06-22T17:28:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jack\_N](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jack_n/32/37265_2.png) [@Jack\_N](https://discourse.julialang.org/u/Jack_N)\
**Post date:** [June 22, 2022, 5:28pm UTC](https://discourse.julialang.org/t/error-caused-by-sending-vector-int64-to-vector-integer-type-function/83194/1 "2022-06-22T17:28:17Z")

</div>

I know that if I had some function

```julia
function a(b::Integer)

```

then I can call a using parameters of any sub-type of `Integer`, so `Int64` or `Int32`, for example.

I am wondering if there is any way to do the same thing with vectors, by this I mean make some function  
`function u(v::Vector{Integer})`  
which accepts parameters which are vectors whose elements are subtype of the `Integer` type.

Please let me know if there is any way to do this in Julia.

Thank you,

Jack

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [June 22, 2022, 5:30pm UTC](https://discourse.julialang.org/t/error-caused-by-sending-vector-int64-to-vector-integer-type-function/83194/2 "2022-06-22T17:30:33Z")

</div>

The signature should be `u(v::Vector{<:Integer})`. Parametric types in Julia are invariant rather than covariant (or contravariant).

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 22, 2022, 7:17pm UTC](https://discourse.julialang.org/t/error-caused-by-sending-vector-int64-to-vector-integer-type-function/83194/3 "2022-06-22T19:17:33Z")

</div>

This is a FAQ: [Why doesn’t it work to declare `foo(bar::Vector{Real}) = 42` and then call `foo([1])`?](https://docs.julialang.org/en/v1/manual/faq/#Why-doesn't-it-work-to-declare-foo(bar::Vector%7BReal%7D)-42-and-then-call-foo(%5B1%5D)?)
