News for hackers. Stuff that matters.
Re:Go: Redefining For Loop Variable Semantics by iudqnolq on Tuesday October 11, 2022 @11:40AM (#33164706)
If so, it's a bit misleading. The go bug just requires a reference, rather than a lambda. I bucket lambdas into a category of language features I expect to have more sharp edges around capture semantics than references.

Bug:

    var all []*Item
    for _, item := range items {
     all = append(all, &item)
    }
Fix:

    var all []*Item
    for _, item := range items {
     item := item
     all = append(all, &item)
    }

There are no comments on this comment yet.