PRACTICE / UNDERSTAND / REPEAT

Go practice question

Practice channels with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

1 questionAnswers explainedFree · no login

Try this question

Channels · MCQQuestion link ↗

What do these buffered channel receives print, in order?

ch := make(chan int, 2)
ch <- 1
ch <- 2
fmt.Println(<-ch, <-ch)
Choose one answer
Answer & explanation

Answer: 1 2

A channel delivers these sends in FIFO order. The buffer accommodates both sends before receiving.