# Type issue in for loop over items in struct field

**URL:** <https://discourse.julialang.org/t/type-issue-in-for-loop-over-items-in-struct-field/118268>\
**Category:** New to Julia\
**Tags:** code\_warntype, type-stability\
**Created:** [August 16, 2024, 10:54am UTC](https://discourse.julialang.org/t/type-issue-in-for-loop-over-items-in-struct-field/118268 "2024-08-16T10:54:57Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [August 16, 2024, 12:25pm UTC](https://discourse.julialang.org/t/type-issue-in-for-loop-over-items-in-struct-field/118268/4 "2024-08-16T12:25:33Z")

</div>

Now, that’s more complicated, because your `op_vec` must be an abstract container, to support different types of `BasisOperations`. You’ll need to use some type of `sum types`. For example, for a recently posted and useful package:

```julia-repl
julia> using DynamicSumTypes

julia> @sumtype SumTypeBasisOperations(AOperation, BOperation) <: BasisOperation
SumTypeBasisOperations

julia> function fun_test2()
           aux = Aux(SumTypeBasisOperations[AOperation(), BOperation()])
           for op in aux.op_vec
               continue
           end
       end
fun_test2 (generic function with 1 method)

julia> @code_warntype fun_test2() # clean

```

see: [[ANN] DynamicSumTypes.jl v3](https://discourse.julialang.org/t/ann-dynamicsumtypes-jl-v3/116741)

---

_[View the full topic](https://discourse.julialang.org/t/type-issue-in-for-loop-over-items-in-struct-field/118268)._
