I’m trying to play around with Groovy closures. Here is what I have:
class WaitLoaderConstrains{
def methodMissing(String methodName, args) {
if(methodName == "wait")
{
def a = args[0] as Map
println "Author is " + a['name']
}
}
}
class Author {
def name1 = "author name"
static constraints = {
wait name: name1 , time: 123
}
}
def a = new Author()
a.constraints.delegate = new WaitLoaderConstrains()
a.constraints()
but this sadly throws the exception:
groovy.lang.MissingPropertyException: No such property: name1 for class:
Author
Possible solutions: name1
at Author$__clinit__closure1.doCall(Script1.groovy:17)
at Author$__clinit__closure1.doCall(Script1.groovy)
at Script1.run(Script1.groovy:26)
why the closure’s can’t access, name1 from the same Author class?
Is it a bug or I'm missing something here?
--
View this message in context:
http://groovy.329449.n5.nabble.com/Change-closures-delegate-results-in-no-property-exception-tp5720902.html
Sent from the groovy - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email