tipsy
05/02/2018, 2:14 PM@FunctionalInterface
interface JsonToObjectMapper {
fun <T> map(json: String, targetClass: Class<T>): T
}
var jsonToObjectMapper = object : JsonToObjectMapper { // use lambda here somehow?
override fun <T> map(json: String, targetClass: Class<T>): T {
}
}
according to this SO post (https://stackoverflow.com/questions/22588518/lambda-expression-and-generic-method/22588738#22588738) you can't combine generics and lambdas in java, but is it possible to achieve in kotlin somehow?Czar
05/02/2018, 2:33 PMvar jsonToObjectMapper = JsonToObjectMapper<String> { json, _ -> json }
tipsy
05/02/2018, 2:37 PMCzar
05/02/2018, 3:06 PM