Skip to content

Instantly share code, notes, and snippets.

@mkock
Created August 20, 2020 19:01
Show Gist options
  • Select an option

  • Save mkock/b874f7926db6ca7ce40d2fc0c488b03d to your computer and use it in GitHub Desktop.

Select an option

Save mkock/b874f7926db6ca7ce40d2fc0c488b03d to your computer and use it in GitHub Desktop.
Bus Ride, code snippet 07
// UpdatePassengers calls function visitor for each Passenger on the bus. Passengers are passed by reference and may be modified.
func (b *Bus) UpdatePassengers(visitor func(*Passenger)) {
ps := make(map[string]Passenger, len(b.passengers))
for ssn, p := range b.passengers {
visitor(&p)
ps[ssn] = p
}
b.passengers = ps
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment