For example, I defined a method:
def hello(String name) {
println("Hello " + name)
}
I want to the the name of argument in runtime:
def hello(String name) {
println("The name of the parameter of this method is: " + getParamName())
// getParamName() will be `name` here
}
And, I expect to get the passed name of the parameter:
def hello(String name) {
println("Passed parameter name: " + getPassedName())
}
String user1 = "someone"
hello(user1)
It will print:
Passed parameter name: user1
Notice, here is user1, the variable name!
I know this is difficult, since java/groovy/scala can't do it. But I think it's a very useful feature(especially for web-framework design). Is there a language can do it?