How to get names of method's parameters

Hi all

Is there possibility to get names of method’s parameters inside method code? Can anyone show example of it?

this is my current "bad solution" (i have to write method name)

class Greeter() {

  fun greet(name: String) {
  val c = Greeter::class;
  for (m in c.memberFunctions) {
           if (m.name == “greet”) {
           val p = m.parameters
           println(p.toString())
           }
  }
  println(“Hello, ${name});
  }
}

fun main(args: Array<String>) {
  Greeter().greet(“UserName”)
}

I found another solution

val p = Greeter::greet.parameters

but know I have one more question: How to get pairs ParamName, ParamValue at function greet?

This is not possible. The JVM has no API that would allow to introspect the local variables or parameters of the current method invocation dynamically.