https://kotlinlang.org logo
i

iseki

03/12/2020, 2:50 PM
Hi, How to get reified type parameter nested? I means
inline fun <reified T: Any> awsl()
If I use it as:
awsl<List<String>>()
How to get the
String
from
T
? Thank you
e

Evan R.

03/12/2020, 2:55 PM
Looks like you can use
typeOf<T>()
as of Kotlin 1.3.50 according to this StackOverflow answer: https://stackoverflow.com/a/36253311
You’ll get a
KType
from that function, then you can use
KType.arguments
to get the parametrized type arguments of the type
i

iseki

03/12/2020, 3:00 PM
Thank you. I will have a look
k

Kroppeb

03/12/2020, 3:33 PM
Is T always a
List
?
2 Views