Having this `sealed class`? ``` sealed class Resul...
# announcements
j
Having this
sealed class
?
Copy code
sealed class ResultWrapper<T> {
data class Success<T>(val data: T) : ResultWrapper<T>()
data class Unauthorized(val exception: UnauthorizedException) : ResultWrapper<Nothing>()
data class Forbidden(val exception: ForbiddenException) : ResultWrapper<Nothing>()
data class Network(val exception: NetworkException) : ResultWrapper<Nothing>()
data class NotFound(val exception: NotFoundException) : ResultWrapper<Nothing>()
data class BadRequest(val exception: BadRequestException) : ResultWrapper<Nothing>()
data class Error(val exception: Exception) : ResultWrapper<Nothing>()
}
Then I have a method that returns a
ResultWrapper<T>
but I'm only able to return the
ResultWrapper.Success(it)
how can I return the other ones?
d
What happens when you try to return the other ones?
j
I solved it adding a <T> in front and changing the <Nothing> by <T>.
k
I think
sealed class ResultWrapper<out T>
should have worked fine too.
j
True that.