Unless you're sending the list to the function as a parameter or you're willing to have a more "precise" function for that case, I don't think so
fred.deschenes
07/25/2018, 7:36 PM
something like
inline fun <reified L, reified T: List<L>> fooList()
fred.deschenes
07/25/2018, 7:37 PM
Otherwise you could do
Copy code
inline 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 dodgy
r
rocketraman
07/25/2018, 7:38 PM
Yeah, I like the more precise function approach...