https://kotlinlang.org logo
Title
d

Dico

09/16/2019, 9:15 AM
Is there a good reason why
SendChannel.offer
throws instead of returning
false
? If so, why is there not an equivalent that never throws?
v

Vsevolod Tolstopyatov [JB]

09/16/2019, 5:34 PM
Not really, initially it was done only to be consistent with
send
. We are thinking of changing that in #974
If so, why is there not an equivalent that never throws?
Unfortunately, no, because we have a compiler problems related to inline classes. You can write your own extension with an optimistic
isClosedForSend
check +
try { ... } catch { ... }
also, please write your use-case in #974 for this behaviour. The more information we have, the better solution we can implement