You can think loosely of channels like pipes for fluid - pour it in one end and out at the other.
By including the arrow
<- chan or
chan <-, you are achieving three things:
- You are making it clear that the parameter is one end of a channel.
- You are expressing clearly which end is being supplied.
- You are giving more information to the compiler for checking. If the function body tries to use the wrong end of the channel, the compiler can raise an error. These are good reasons to show the channel end whenever possible.
| when you see | which end is of the channel is it for? |