Go Brain Teasers:

Please use the following format for the title of this thread (then simply delete/replace this text with the content for the thread):

Title: Go Brain Teaser (page 24)
Example: Error on example code for the fix of the sleep_sort code

go func(i int) {
    defer wg.Done()
    time.Sleep(time.Duration(n) * time.Millisecond)
    fmt.Printf("%d ", i)
}(n)

In this example, the variable n is still used when “i” was used as an argument for the code.

1 Like