Created
August 20, 2020 19:01
-
-
Save mkock/b874f7926db6ca7ce40d2fc0c488b03d to your computer and use it in GitHub Desktop.
Bus Ride, code snippet 07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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