vendredi 27 décembre 2019

How to check if class property is type of List in Kotlin

How can I check if an attribute of a class is type of List? The following code snippet is what I want but it doesn't work.

class MyClass(val attr:List<String>)
fun main(args: Array<String>) {
    var prop = MyClass::attr
    if(prop.returnType.classifier is List<*>)
        println("Property is type of List")
}




Aucun commentaire:

Enregistrer un commentaire