```val channel = ... for (message in channel) { <...
# coroutines
u
Copy code
val channel = ...

for (message in channel) { <-------
	//
}

while (true) {
	val message = channel.receive() <-------
}
What exactly is the
for ... channel
syntax sugar for? is it the while loop as I wrote it? I'm looking at sources of the iterator
private class Itr<E>(@JvmField val channel: AbstractChannel<E>) : ChannelIterator<E> {
and in it's
next
implementation, there is no
receive
.. so idk? (the context is ktor websockets; and there's a
receiveDeserialied
helper function I'd like to use)
j
Well it also exits cleanly when the channel is closed which your
while
example doesn't have
1
u
what exactly do I need to do then? since the sources are kinda cryptic
or would you rather ditch the
receiveDeserialized
, its just json parsing bolted on top the text frame
j
I'm on mobile so not sure off the top of my head what the equivalent would be. You could while true, select, and then have onReceive and onClose clauses?