Reputation: 5126
Please look at code sample:
fun <T> query(sql: String, params: JsonArray): T? {
val row = otherfun(sql, params)
return row.mapTo(T)
}
How to pass in mapTo(Class klz) function (It's java function) proper argument?
Upvotes: 1
Views: 35
Reputation: 89668
You need to make your function reified
(and therefore inline
), and then you can use ::class.java
to get a Class
instance:
inline fun <reified T> query(sql: String, params: JsonArray): T? {
val row = otherfun(sql, params)
return row.mapTo(T::class.java)
}
Upvotes: 3