https://kotlinlang.org logo
#getting-started
Title
# getting-started
f

F0X

01/28/2021, 9:48 PM
Is there an idiomatic Kotlin way of doing this (with
T
being a reified type paramter)?
Copy code
SomeClass::class.java.isAssignableFrom(T::class.java)
n

nanodeath

01/28/2021, 9:54 PM
T is SomeClass
?
wait, it'd have to be an instance
t is SomeClass
😛
assuming your type
T
is on one of the inputs, which in my experience it usually is
e

ephemient

01/28/2021, 9:57 PM
Copy code
SomeClass::class.isSuperclassOf(T::class)
(requires kotlin-reflect)
f

F0X

01/28/2021, 9:59 PM
oh yeah forgot I didn't have kotlin-reflect, thx a lot!
and no, I do not have an instance of
T
n

nanodeath

01/28/2021, 10:04 PM
can you share the method signature?
4 Views