Using generic as parameter in constructor Kotlin

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"))
                }

Answer

You can give named parameters in kotlin. That is if more than two constructors or functions with same name exists, we can explicitly specify the parameter as named one. Here I suggest to explicity mention the parameter data.

    if (apiResponse.code() == 200) {
        Observable.just(DataResponse<List<ResultDTO>>(true,data=
        apiResponse.body()?.resultList))
    } else {
        Observable.just(DataResponse(false, "Something went wrong"))
    }