Hello everyone, how do you handle the array-kclass...
# multiplatform
z
Hello everyone, how do you handle the array-kclass problem when you use code like this in your commons library that is shared between JVM and JS?
Copy code
inline fun <reified T> T.call(block: (T)->Unit){
    if (T::class == Array::class){
        error("This is an array")
    }
    block(this)
}
I found the issue regarding that problem, but i dont know if implementing that workaround
isArray
like mentioned in the issue is still the way to go. https://youtrack.jetbrains.com/issue/KT-32839 My implementation of the workaround looks like this:
Copy code
// Commons
expect val KClass<*>.isArray: Boolean
// JS
actual val KClass<*>.isArray: Boolean get() = this == Array::class
// JVM
actual val KClass<*>.isArray: Boolean get() = java.isArray