rocketraman
07/25/2018, 7:28 PMinline fun <reified T: Any?> foo()
, where at my call-site T
is a List<Something>
, is there a way to determine Something
inside the inline fun?fred.deschenes
07/25/2018, 7:34 PMfred.deschenes
07/25/2018, 7:36 PMinline fun <reified L, reified T: List<L>> fooList()
fred.deschenes
07/25/2018, 7:37 PMinline fun <reified T: Any?> foo(t: T){
if (T::class.isSubclassOf(List::class)) {
val list = t as List<*>
if (list.isNotEmpty()) {
val itemType = list.first()!!.javaClass
}
}
}
but that's slightly dodgyrocketraman
07/25/2018, 7:38 PM