Documentation ¶
Overview ¶
Example is for testing out setting channels to nil. Starting up 2 go routines who will produce a set of numbers, and put them on a channel for each go routine. When to go routine is done we close the channel.
We then make a loop with a select, and read all the values from the 2 channels. With OK we check if the channel is closed, and if it is closed we set the channel to nil. The interesting thing bout settign a channel to nil is that it will not be checked anymore in the select, and the case is ignored. Something that can be seen in this example that the print statement inside the case about setting the channel to nil is only printed once.
We then check that both channels are set to nil, and break out of the loop.