christophsturm
10/10/2022, 1:27 PMinline fun <reified C> name() = C::class.simpleName
name<Collection<String>>()
this returns “Collection”. is there a way make it return “Collection<String>“?Joffrey
10/10/2022, 1:29 PMC::class
, because the KClass
type simply doesn't have that information. What you need is KType
, which you can get from a reified C
using typeOf<C>()
.
I don't know off the top of my head how to get a nice string for its name from the KType
, but you might be able to figure that outchristophsturm
10/10/2022, 1:30 PMephemient
10/10/2022, 1:32 PMKType.toString()
will get you kotlin.collections.Collection<kotlin.String>
ephemient
10/10/2022, 1:32 PM