Middle+
Write a function code that merges N channels. All input streams are redirected into one channel. func merge(cs ...<-chan int) <-chan int { ... }
sobes.tech AI
Answer from AI
This code creates an output channel out, starts a goroutine for each input channel that reads from it and writes to out. After all input channels are closed and their data has been read, the output channel is closed. Thus, all values from N channels are merged into a single stream.