# Closure in struct type inference

**URL:** <https://discourse.julialang.org/t/closure-in-struct-type-inference/62180>\
**Category:** Performance\
**Tags:** closure\
**Created:** [June 1, 2021, 9:07am UTC](https://discourse.julialang.org/t/closure-in-struct-type-inference/62180 "2021-06-01T09:07:49Z")\
**Posts on this page:** 1\
**Showing post:** 8

<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:** [June 1, 2021, 2:04pm UTC](https://discourse.julialang.org/t/closure-in-struct-type-inference/62180/8 "2021-06-01T14:04:57Z")

</div>

> [@cdawg](#):
>
> Honestly not 100% sure if in my case I should have the `mutable` here or not.

Probably not. Using a ref, or an array of a single element, are adequate solutions. Or using `Setfield`. Here is a discussion on the alternatives: [Mutable scalar in immutable object: the best alternative?](https://discourse.julialang.org/t/mutable-scalar-in-immutable-object-the-best-alternative/57401)

ps: `Array{Virus,1}` is the same as `Vector{Virus}`. Be careful that `Virus` should be a concrete type here, or that vector would be abstract as well. If `Virus` is abstract (has parameters, you should better parameterize the population struct as well for the type of Virus).

---

_[View the full topic](https://discourse.julialang.org/t/closure-in-struct-type-inference/62180)._
