Assuming we have such method ``` putData(property:...
# announcements
i
Assuming we have such method
Copy code
putData(property: KProperty1<out Any?, Any?>, value: Any?) { }
Is there any way to check is
property
is of the same type as
value
?
d
At run time or compile time?
i
Runtime
l
Depends if you want to accept subclasses or consider them as not same type.
Also depends on if you support JVM only or multiplatform
d
value != null && property.type.classifier!!.java.isAssignableFrom(value.javaClass)
i
@louiscad yah I want to accept subclasses and target JVM. Do you have other suggestion than @Dico?
l
His solution seems a good one. Check for yourself it works the way you expect. It it doesn't, you still have a good starting point @igor.wojda
👍 1