Is there a way to tell if a class is an instance o...
# getting-started
i
Is there a way to tell if a class is an instance of a Kotlin interface without doing a cast? Basically I have a class that I load from an external jar using URLClassLoader.loadClass(). The only way I can figure if it's an instance of the interface is I then create an instance of the class and try to cast it. So basically
val testClass = urlClassLoader.loadClass("some-class").newInstance() as? InterfaceClassName
If testClass is null then I assume it wasn't an instance of that interface. Any easier way? Thanks!