# Array of Functions type matching

**URL:** <https://discourse.julialang.org/t/array-of-functions-type-matching/60843>\
**Category:** General Usage\
**Tags:** type\
**Created:** [May 9, 2021, 10:41pm UTC](https://discourse.julialang.org/t/array-of-functions-type-matching/60843 "2021-05-09T22:41:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_McVay](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_mcvay/32/4307_2.png) [@Paul\_McVay](https://discourse.julialang.org/u/Paul_McVay)\
**Post date:** [May 9, 2021, 10:41pm UTC](https://discourse.julialang.org/t/array-of-functions-type-matching/60843/1 "2021-05-09T22:41:20Z")

</div>

I have an array of functions. If I try to pass that array to another function that has the parameter type of `Array{Function, 1}`, I get a type mismatch error. Here is a working example.

```julia
function test()
    return function()
        return rand(10)
    end 
end
arr = [test() for i in 1:3]

function test2(arr::Array{Function, 1})
    println([x() for x in arr])
end

julia> test2(arr)
ERROR: MethodError: no method matching test2(::Array{var"#103#104",1})
Closest candidates are:
  test2(!Matched::Array{Function,1}) at none:1
Stacktrace:
 [1] top-level scope at none:1
 [2] run_repl(::REPL.AbstractREPL, ::Any) at /build/julia/src/julia-1.5.4/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:288

julia> arr isa Array{Function, 1}
false

julia> arr[1] isa Function
true

```

Why is this happening?

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [May 9, 2021, 10:48pm UTC](https://discourse.julialang.org/t/array-of-functions-type-matching/60843/2 "2021-05-09T22:48:31Z")

</div>

Every `function` has it’s own type, so `typeof(arr)` is `Vector{typeof(test))`. If you define ` function test2(arr::Vector{<:Function})`, everything will work (although if you have an array of different functions, it will be type unstable).
