How can I use `is` with generics? For example if...
# getting-started
a
How can I use
is
with generics? For example if the generic is
<T : SomeClass>
how can check if T is a specific child of
SomeClass
?
j
is
cannot check the type
T
, it can only check an instance of
T
, so you would have to have an instance or a
KClass<T>
to do what you want
a
In my case, I have a class which returns an instance of
T
, however it is the super class. It also isn't always ensured that the returned value is an instance of
T
, so I want to check if that is the case, and then create an instance of
T
with the properties of the returned values.
m
Use reified inline
a
I get "Cannot use
T
as reified param"
j
Can you share some code of your setup, I am not entirely sure I understand your situation, especially the part where the instance of
T
is not guaranteed to be one