News for hackers. Stuff that matters.
Re:Go is Not Python by majewsky on Friday June 23, 2017 @04:46AM (#14617805)
Alternative options of solving this issue include `break`ing when the right option is found (so the loop variable doesn't get overwritten again) or moving everything into a function:

  func findByName(students []*Student, name string) *Student {
    for _, s := range students {
      if s.name == name {
        return s
      }
    }
    return nil
  }
Both options have the added advantage of stopping iteration as soon as the result is found.

There are no comments on this comment yet.