anyone know how to compare a KType to a actual typ...
# reflect
t
anyone know how to compare a KType to a actual type? I want to say something like
if( someProp.returnType == Double::class )
In this case I could create an instance of a
Double
and get it's type... but pretend the type is of a class that it's not easy/possible to get an instance of easily.
d
KType.classifier
will give you the "raw type" (either
KClass
or
KTypeParameter
) which you can then compare to e.g.
Double::class
t
Oooo! classifiers. a new concept to me... I'll read up. But yeah, that compare totally works in my code. Thanks!
413 Views