Search code examples
kotlininstanceof

Get type of a variable in Kotlin


How can I find the variable type in Kotlin? In Java there is instanceof, but in Kotlin it does not exist:

val properties = System.getProperties() // Which type?

Solution

  • You can use like this:

    val value="value"
    println(value::class.java.typeName)