Is there a way to use the NV macro to get to the original name when used in a method?

```groovy

class Person {
  int id
  String Name
  Person(int id, String name) {
    this.id = id
    this.name=name
  }
}

def per = new Person(1, 'Per')
println "The person object is named ${NV(per).name}"

def someMethod(Person person) {
  println "The person object is named ${NV(person).name}"
}

someMethod(per)

```

will print

```
The person object is named per
The person object is named person
```

I would like to get to the name of the variable it was given when calling the someMethod (i.e. per), not what the variable is called in the method.

The real use case is to allow script users to create a class from my library where i want to use the variable name they gave it in my library.

Is there any way to do that?

Regards,

Per

Reply via email to