Hello :wave: Just wondering if anyone knows how to...
# reflect
d
Hello 👋 Just wondering if anyone knows how to detect whether given property is a lambda, e.g. given
Copy code
class Foo(val bar: () -> Bar)
// or
class Foo(val bar: suspend () -> Bar)
how to check whether
bar
is actually a lambda. I was hoping that simple
KProperty.returnType is Function<*>
would do the trick, sadly that returns false...
e
returnType is a KType, not a KClass or an instance
you could do something like
Copy code
returnType.isSubtypeOf(typeOf<Function<*>>())
👍 1
d
nice that seems to do the trick
thanks