kotlin
class Person(val name: String) {
fun sayHello() {
println("Hello, $name!")
}
}
kotlin
import kotlin.reflect.full.memberProperties
import kotlin.reflect.full.functions
fun main() {
val person = Person("John")
val properties = person::class.memberProperties
properties.forEach { property ->
println("${property.name} = ${property.get(person)}")
}
val sayHelloFunction = person::class.functions.find { it.name == "sayHello" }
sayHelloFunction?.call(person)
}