https://kotlinlang.org logo
Title
l

louiscad

08/24/2018, 6:23 PM
@withoutclass Always use
consume
or
consumeEach
. BTW, this is getting me wondering if
for
loop on a channel without
consumption
should raise a warning…
☝️ 1
b

bj0

08/24/2018, 6:25 PM
what about in an actor?
l

louiscad

08/24/2018, 6:29 PM
I always use
consumeEach
, even in `actor`s, except when I need to use
continue
or
break
(but I still use
consume
). A channel may need to be closed to not leak resources. It's possible `actor`s don't need consumption of the internal
ReceiveChannel
though. Can anyone confirm?
b

bj0

08/24/2018, 6:32 PM
i was talking about the internal channel, since you close it from outside, and you typically loop on it until it's closed so
consume
is probably redundant
l

louiscad

08/24/2018, 6:33 PM
Yes, that's what I understood, and I think you're right about this case (which may be reproduced in some cases)
b

bj0

08/24/2018, 6:34 PM
i have parsing code that uses
for
without
consume
, though it has no way to break out of the
for
except an external close, so that would be the same case I guess