Obtaining a KClass from an object


#1

How can I obtain a KClass from an object? I'm looking for the equivalent of Java's Object.getClass(). I've looked in the docs but haven't found anything, am I missing something?

This works but I can’t believe it’s the best way to do it:

foo.javaClass.kotlin

#2

Yes, this is currently the preferred way to obtain a KClass instance from an object. This will improve at some point in the future and will be just "foo::class"