getClass

fun <T : Any> T.getClass(): KClass<T>

Extension function to get the KClass of any non-null object. This is a convenient alternative to T::class when dealing with generic types, or simply as a replacement for this.javaClass.kotlin.

Return

The KClass representation of the object's class.

Parameters

The non-nullable type of the receiver object.