How do I dynamically get my subclass name from abs...
# announcements
k
How do I dynamically get my subclass name from abstract class? Example I want to replace
GetSubclassNamehere???
with whichever subclass called the someMethod().
Copy code
abstract class A<T> {
    fun someMethod(item: T?) {
        try {
            if (item == null) {
                println("GetSubclassNamehere??? received null item")
                return
            }
        } catch (e: Exception) {
        
        }
    }
}

class B : A<String>() {
}


fun main() {
    val b: A<String> = B()
    b.someMethod(null)
}
d
k
thanks