dimsuz
01/19/2018, 3:18 PMinline + reified
in interfaces, but I still can achieve virtually the same thing with extension functions:
interface Store {
inline fun <reified T> getValue(key: String): T // impossible, no go
// so doing this
fun <T> getValue(key: String, clazz: Class<T>): T // good
}
class StoreImpl : Store {
override fun <T> getValue(key: String, clazz: Class<T>): T {
// code
}
}
inline fun <reified T> Store.getValue(key: String): T {
return this.getValue(key, T::class.java)
}
fun main(args: Array<String>) {
val i: Int = StoreImpl().getValue("hello")
}
Andreas Sinz
01/19/2018, 3:56 PMgildor
01/21/2018, 5:14 AMdimsuz
01/26/2018, 11:47 AMgildor
01/26/2018, 11:22 PM