isClosed

Whether the operation failed because the channel was closed.

If this returns true, the channel was closed for the operation that returned this result. In this case, retrying the operation is meaningless: once closed, the channel will remain closed. isSuccess will return false. exceptionOrNull can be used to determine the reason the channel was closed if one was given.

If this returns false, subsequent attempts to perform the same operation may succeed.

val result = channel.trySend(42)
if (result.isClosed) {
println("The channel is closed.")
if (result.exceptionOrNull() != null) {
println("The reason: ${result.exceptionOrNull()}")
}
}