如何将参数传递给函数,然后将其用作通用类型?
private fun createRequest(data: Data, class: Class<out UploaderTask>): OneTimeWorkRequest {
return OneTimeWorkRequestBuilder<class>().build()
}
答案 0 :(得分:0)
我找到了答案
private inline fun <reified T : UploaderTask>createRequest(data: Data): OneTimeWorkRequest {
return OneTimeWorkRequestBuilder<T>()
.setInputData(data)
.build()
}