Channel properties
You can obtain information about a channel variable by accessing the properties it exposes. The properties of the channel include len
, cap
, and closed
. These properties provide the following information about a channel at the time of accessing them:
cap
is an integer property that indicates the capacity of the channel. This is0
for the unbuffered channel. In the case of a buffered channel, thecap
property indicates the maximum number of values a channel can hold.len
is an integer property that indicates the actual number of values that the channel holds at the time of accessing this property. At any given point in time, thelen
value can only be less than or equal to thecap
property.closed
is a Boolean property, and when its value istrue
, it indicates that the channel is closed. If a channel is not closed, the value of theclosed
property will befalse
.
Understanding channel properties using examples
In this section, we will understand...