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?
CodePudding user response:
Just add Throwable
constraint to R
(see documentation):
data class MyClass<T, out R : Throwable>(
val data: T? = null,
val error: R? = null
)