How to avoid variable capturing in `foreach` loop with lambdas?
thebluepandabear
therealbluepandabear at protonmail.com
Mon Jan 9 00:25:18 UTC 2023
> : create a copy of the value that is currently present in one
> particular iteration of the `foreach` by creating a function
> literal that takes your `struct` as a paramter. This works
> because structs are value types, so passing it to the function
> creates a copy.
Thanks, your solution seems to be the most elegant one yet, I
recently came across the similar problem and I realized that the
other answer was too long and verbose.
More information about the Digitalmars-d-learn
mailing list