I m using two constructor with different input types one as string and other as generic. The problem is while using Kotlin its only using the string constructor and ignores the generic
class DataResponse<T> {
var isSuccess: Boolean = false
private set
var errorMessage: String? = null
var data: T? = null
constructor(success: Boolean, data: T) {
this.isSuccess = success
this.data = data
}
constructor(success: Boolean, errorMessage: String) {
this.isSuccess = success
this.errorMessage = errorMessage
}
}
usage
if (apiResponse.code() == 200) {
Observable.just(DataResponse<List<ResultDTO>>(true,
apiResponse.body()?.resultList)) ---> **(error on this line forcing to convert it to string)**
} else {
Observable.just(DataResponse(false, "Something went wrong"))
}