Hacker News new | ask | show | jobs
by gigatexal 1469 days ago
In the closure example does declaring a new variable and setting its value to the iterative or the thing being passed in, does that mitigate the pass by reference issue?
1 comments

Yes.

    for i := 0; i < 10; i++ {
        i := i
        ...
    }
https://go.dev/play/p/P7TunJCL7RS
Thank you!

The example is brilliant. Thanks.