I am trying to dynamically evaluate a result of another function during a class method call. However, having and issue with the scope of the Eval.
class A {
private String a
public A() {
a = 5
}
public whatIsA() {
return a
}
public func() {
return "\\${whatIsA()}"
}
public test() {
return Eval.me("\"\${func()}\"")
}
}
def a = new A()
a.test()
Exception thrown: groovy.lang.MissingMethodException: No signature of method: Script1.func() is applicable for argument types: () values: {}
groovy.lang.MissingMethodException: No signature of method: Script1.func() is applicable for argument types: () values: {}
at Script1.run(Script1.groovy:1)
at A.test(Script7:17)
at Script7.run(Script7:22)
How can I pass the scope of the A class instance into the Eval script?
Try this?