https://kotlinlang.org logo
#reflect
Title
# reflect
d

dmcg

08/03/2019, 9:55 PM
Is there anything in the stdlib that captures the class and nullability of a type?
d

diesieben07

08/05/2019, 7:27 AM
KType
would do that, but afaik the only way to obtain it without the reflection library is
typeOf
d

dmcg

08/06/2019, 7:25 AM
Thanks. I remember now that I was using KType, but it’s hard to get hold of one. Is this https://gist.github.com/udalov/bb6f398c2e643ee69586356fdd67e9b1 still the sanctioned way of converting a reified T to a KType please @udalov?
d

diesieben07

08/06/2019, 7:37 AM
No, the stdlib has
typeOf
intrinsic now.
val myType = typeOf<List<String>>()
works fine
d

dmcg

08/06/2019, 7:41 AM
Ah, is still @ExperimentalStdlibApi I see but I’ll try it on for size. Cheers