https://kotlinlang.org logo
Title
s

Slackbot

12/12/2018, 11:55 AM
This message was deleted.
t

Tolriq

12/12/2018, 11:57 AM
Because main is ended before it can start.
launch { start a coroutine and immediately returns, so for the last call, you start the coroutine, exit the foreach block and main is ended
add a delay after the last } and see if it works 😉
m

marstran

12/12/2018, 12:15 PM
The default capacity of the actor-channel is 0 (Rendevouz), so main will suspend on
send
until the actor reads the message. When the actor reads the final message, main will immediately finish before the actor can has time to actually process it.
That's why you only miss the last one.
b

bj0

12/12/2018, 4:00 PM
the "structured" way to fix this is to change it to
CoroutineScope.testActor = actor<Int> {
1
and then close the actor