Hello and welcome to the golden programming language course in this session.
We want to talk about the others concurrency concepts.
Receive all values from a channel by full range, look full range, Lou can be used to receive data
from the channel until it is closed for days.
Lou will keep receiving from the channel.
The only way for range Lou to exit is to close the channel.
Now let's go to Villa School curriculum to talk about it.
First, create a function that accept a challenge as argument and iterate on channel value and support
on off channel values together.
So we write for each song and define the value of a life series.
By the time it
first define, a variable like sum equals zero and define the full range loop for value.
Calling equals branch in search.
And some the value of Channel Together, Song Plus equals value and end of the work of the follow up,
we displayed a total of somebody of a f f song total to Colin Firth and the brackets and and set value
the song.
Now go to main function and create a channel and send data to it, then call and go routine and pass
these generous argument of function.
Now, create a channel like search calling equals killing, make function and sit chan and and Triassic
in argument now set values to the channel search channel operate on our set to see its channel operator
answer to a game and see its channel operator and said two values to the channel.
Now, Carlos create a channel by the close function, close and set seizures or argument now calling
Go Routine and pause channel to eat, song and toss Sia's tweet as our unit.
And in the end of the work of function, we said at timeously time, Dot's lead time that millisecond
multiplication 200 OK, reformat the court, save the project and execute the program, go round the
clock.
This means that Google now we can see the output song total is six in above program.
First, we created a channel in the main function.
We sent three values to the channel and after death we closed the channel.
Then we called the song function and we passed the channel to that function in the song function.
We did the full range loop over the channel.
After iterating over all the values in the channel and the full range, no bill exists since the channel
is closed.
Now the question which comes to the mind is that what happens if you don't close the channel in the
main function?
Now go to main function and commenting the line in which they are closing the channel in and around
the program again.
Save the project and execute the program again.
Now we can see the output.
We have error.
It will answer output deadlock because full range loop will never finish in the song function.
In order not to prolong the time of decision, we will finish it and we will continue the content in
the next session.
Goodbye.