# Simple type problem

**URL:** https://discourse.julialang.org/t/simple-type-problem/70958
**Category:** Performance
**Tags:** structtypes
**Created:** [November 4, 2021, 2:45pm UTC](https://discourse.julialang.org/t/simple-type-problem/70958 "2021-11-04T14:45:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Igor\_Douven](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/igor_douven/32/8433_2.png) [@Igor\_Douven](https://discourse.julialang.org/u/Igor_Douven)
#### Post date: [November 4, 2021, 2:45pm UTC](https://discourse.julialang.org/t/simple-type-problem/70958/1 "2021-11-04T14:45:39Z")

</div>

I have an abstract type,

```julia
abstract type AT end

```

and two `mutable struct`s that are subtypes of `AT`:

```julia
mutable struct S1 <: AT
    #something
end

mutable struct S2 <: AT
    #something
end

```

I would like to define a function that takes as argument vectors that can contain either `S1`s or `S2`s or both. I had hoped that the following would work:

```julia
function fnc(v::Vector{AT})
    #something
end

```

However, it turns out that it works only if the vector contains **both** `S1`s and `S2`s. If, for instance, the argument is a `Vector{S1}` the function throws an error. I’m sure there is a simple solution but I can’t think of it. Help would be much appreciated.

---

<div class="post-metadata">

### Author: ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)
#### Post date: [November 4, 2021, 2:51pm UTC](https://discourse.julialang.org/t/simple-type-problem/70958/2 "2021-11-04T14:51:16Z")

</div>

You’ll want to specify a subtype `<:` relationship for the elements of the vector:

```julia
function fnc(v::Vector{<:AT})

```

---

<div class="post-metadata">

### Author: ![Igor\_Douven](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/igor_douven/32/8433_2.png) [@Igor\_Douven](https://discourse.julialang.org/u/Igor_Douven)
#### Post date: [November 4, 2021, 3:07pm UTC](https://discourse.julialang.org/t/simple-type-problem/70958/3 "2021-11-04T15:07:08Z")

</div>

Perfect! Thank you very much.
