Hi,

I have a project where I need to append to a result list, several objects depending on conditions. A MWE is presented in the following code. In practice, I have more subtypes of `ABS`

(like ~10). I would like `foo`

to be the most efficient (fastest).

To me, the type of `res`

is not known and so `foo`

is not efficient. I tend to think that a different structure is needed to handle this situation. However, I noticed:

Surprisingly to me, using

`@code_warntype`

does not reveal type unstability.

Hence:

- is it the best way to handle this situation?
- should I enforce
`res = Vector{Union{A{T},B{T},C{T}}(undef, 0)`

? (and later with 10s of subtypes?) - should I leave it like that?

Thank you for your help,

```
using Revise
abstract type ABS end
struct A{T} <: ABS ;a::T;end
struct B{T} <: ABS ;b::T;end
struct C{T} <: ABS ;b::T;end
function foo(x::T) where T
res = Vector(undef, 0)
push!(res, A(x))
push!(res, B(x))
for i=1:13
r = rand(T)
if r < 0.25
push!(res, A(r))
elseif r<0.75
push!(res, B(r))
else
push!(res, C(r))
end
end
res
end
foo(1.2)
```