3 ms·
Channels are just blocking queues with weirder semantics.
by EdwardDiego 5y ago
Channels are just blocking queues with weirder semantics.
- ackfoobar 5y agoAt first I misread "wider" and agreed. In Go/Kotlin, one can atomically take from/send to exactly one channel with the `select` call. Then I agree with "weirder" as well, in the case of Go channels. A send on a nil channel blocks forever. Why?
- EdwardDiego 5y agoHaha yep, it's those edge cases, to quote one of the many web pages documenting it: Channels exhibit the following properties: * send to a nil channel blocks forever * receive from a nil channel blocks forever * send to a closed channel panics * receive from a closed channel returns the zero value immediately I have this bookmarked because I don't write Go enough to remember it by heart.