Skip to content

Commit

Permalink
server/server.go: Another attempt at fixing up the code in the docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandertv committed Nov 25, 2024
1 parent cdf2c5e commit ce336a4
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ func (srv *Server) Listen() {
// returned are only valid within the block of the for loop used to iterate over
// them:
//
// for p := range srv.Accept() {
// // p is valid here
// go func() {
// // p is no longer valid here
// }()
// }
// // p is no longer valid here
// for p := range srv.Accept() {
// // p is valid here
// go func() {
// // p is no longer valid here
// }()
// }
// // p is no longer valid here
func (srv *Server) Accept() iter.Seq[*player.Player] {
return func(yield func(*player.Player) bool) {
for {
Expand Down Expand Up @@ -188,13 +188,13 @@ func (srv *Server) MaxPlayerCount() int {
// passed. Passing nil is otherwise valid. Players returned are only valid
// within the block of the for loop used to iterate over them:
//
// for p := range srv.Players() {
// // p is valid here
// go func() {
// // p is no longer valid here
// }()
// }
// // p is no longer valid here
// for p := range srv.Players() {
// // p is valid here
// go func() {
// // p is no longer valid here
// }()
// }
// // p is no longer valid here
//
// Collecting all values from the iterator using a function such as
// slices.Collect immediately invalidates the players because their transactions
Expand Down

0 comments on commit ce336a4

Please sign in to comment.