Closed Dark-Existed closed 3 years ago
I implemented Result
sealed class Result<T> {
class Success<T>(val value: T) : Result<T>()
class Failure<T>(val error: Throwable) : Result<T>()
}
inline fun <R, T> Result<T>.fold(
onSuccess: (value: T) -> R,
onFailure: (exception: Throwable) -> R
): R = when (this) {
is Result.Success -> onSuccess(value)
is Result.Failure -> onFailure(error)
}
val <T> Result<T>.isSuccess: Boolean
get() = when (this) {
is Result.Success -> true
else -> false
}
val <T> Result<T>.isFailure: Boolean
get() = when (this) {
is Result.Failure -> true
else -> false
}
fun <T> Result<T>.getOrNull(): T? =
when (this) {
is Result.Success -> this.value
else -> null
}
@Dark-Existed Why a custom result for fixing the issue for the classcastexception? how can i use the custom class in this scenario? Could you explain more about the cutom result and the usage in the issue?
hi, I have the similar issue to #1035
the following is my log
My code is folling
build.gradle
So is any I can do to solve this problem?