Mutable struct vs closure

for this particular example, yes, Vector would do.

But what I concern is to have an “object” that has some fields that changes over time. Then, there’re two ways doing that: define a mutable struct type and define ! methods for the type; or, use closures.

The closure approach, which seems unpopular in Julia, seems to give better “encapsulation”, because the captured variables could only be access thru the closures returned.

Or, is it a better “think Julia” way to do this?