Reputation: 321
Create a generic data class which has one variable data Type
data class <T> GenericResponse(
val success: Boolean,
val message: String,
val data: T
)
To use it: GenericResponse<SomeOtherDataClass>
How to do this in kotlin?
Upvotes: 2
Views: 2843
Reputation: 37710
Just put the <T>
after the class name:
data class GenericResponse<T>(
val success: Boolean,
val message: String,
val data: T
)
Upvotes: 10