architecture-samples
architecture-samples copied to clipboard
toString doesn't override dataClass's tostring
The toString function in this class will never be called, at least I don't know where this would be called since this doesn't override the toString() from dataClasses:
sealed class Result<out R> {
data class Success<out T>(val data: T) : Result<T>()
data class Error(val exception: Exception) : Result<Nothing>()
object Loading : Result<Nothing>()
override fun toString(): String {
return when (this) {
is Success<*> -> "Success[data=$data]"
is Error -> "Error[exception=$exception]"
Loading -> "Loading"
}
}
}
Hi, i will work on this
Hi, try it. This work to me
when(result.javaClass){
Result.Loading::class.java -> {
//TODO: Loading
}
Result.Success::class.java -> {
// TODO: Sub data
}
Result.Error::class.java -> {
// TODO: error sub data
}
}