Question --- Channel.consumeEach() (a suspend func...
# coroutines
p
Question --- Channel.consumeEach() (a suspend function) seems to be implemented internally as
for (e in this) action(e)
— which looks like it’s implicitly calling this.iterator() and iterating over the channel that way. I assume that can’t actually be what’s happening (right?) since Iterator.next() is blocking. Or does Channel.consumeEach() actually block?
answer: whoa. ChannelIterator.hasNext() is a suspend function. I didn’t know you could do that.
wowee.
c
Yep, they have a specific Iterator that can suspend to enable these syntaxes