Is there any way to get reified type in a class fu...
# getting-started
s
Is there any way to get reified type in a class function?
Copy code
class Container<T> {
    fun useContainedClassType() {
        T::class.java
    }
}
d
You could take it in as a constructor argument or do some tricks with inline functions. Depends on your use case.
s
In my case, this logic is in a base and derived class specifies the actual type
using the type parameter
I could have a hook in the base and have derived class specify the class but was hoping to avoid that as the type is already in the parameter
k
Unfortunately that isn't really possible.
s
Okay, going with the hook. Derived class developers can live that
I guess, this comes from Java type erasure, nothing that kotlin can do here
👌 3