Function
is an abstract type. Look at
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 for example for some options.