# Type instability if I map over array of functions

**URL:** <https://discourse.julialang.org/t/type-instability-if-i-map-over-array-of-functions/12817>\
**Category:** General Usage\
**Created:** [August 2, 2018, 10:32am UTC](https://discourse.julialang.org/t/type-instability-if-i-map-over-array-of-functions/12817 "2018-08-02T10:32:25Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [August 2, 2018, 10:43am UTC](https://discourse.julialang.org/t/type-instability-if-i-map-over-array-of-functions/12817/2 "2018-08-02T10:43:54Z")

</div>

`Function` is an abstract type. Look at

```julia
julia> typeof(init_add(StructA(1.1)))
##3#4{StructA}

julia> typeof(init_add(StructB(2.2)))
##5#6{StructB}

```

Since these types are different, iterating over a `Vector` containing elements of both types is the same as iterating over any other type-heterogeneous collection (e.g. `Number[1, 2.0]`). See [this post](https://discourse.julialang.org/t/is-there-a-way-to-forward-getindex-for-tuples-in-a-type-stable-way/2889/20) for example for some options.

---

_[View the full topic](https://discourse.julialang.org/t/type-instability-if-i-map-over-array-of-functions/12817)._
