Issue
I have such class
data class MyClass<T, out R>(
val data: T? = null,
val error: R? = null
)
But actually I want my error
to extend Throwable
, for example.
How should I declare MyClass for this purpose?
Solution
Just add Throwable
constraint to R
(see documentation):
data class MyClass<T, out R : Throwable>(
val data: T? = null,
val error: R? = null
)
Answered By - Commander Tvis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.