PRACTICE / UNDERSTAND / REPEAT
Go: Channels
Practice channels with self-contained questions. Check your answer, then use the explanation to understand the reasoning.
20 questionsAnswers explainedFree · no login
Question 1 of 20
What do these buffered channel receives print, in order?
ch := make(chan int, 2)
ch <- 1
ch <- 2
fmt.Println(<-ch, <-ch)
Answer & explanation
Answer: 1 2
A channel delivers these sends in FIFO order. The buffer accommodates both sends before receiving.