On 03.04.2016 17:33, OC wrote:
[...]
===
6 /tmp> <q.groovy
class q {
static main(av) {
ExpandoMetaClass.enableGlobally()
Root.metaClass.static.propertyMissing={ name ->
String getter="get${name.capitalize()}"
def body={-> "<$name in $delegate>" }
delegate.metaClass.static."$getter"=body
body.call() // same problem with body(); delegate."$getter"() would work
though
}
println "- ${Root.weird}"
}
}
interface Root {}
7 /tmp> groovy q.groovy
Caught: groovy.lang.MissingMethodException: No signature of method:
java.io.StringWriter.capitalize() is applicable for argument types: () values:
[]
groovy.lang.MissingMethodException: No signature of method:
java.io.StringWriter.capitalize() is applicable for argument types: () values:
[]
at q$_main_closure1.doCall(q.groovy:5)
at q.main(q.groovy:10)
8 /tmp>
so I misunderstood... it was not, that somehow body was not recognized
as closure or such, it is that the execution of code inside fails.
capitalize() is a method on CharSequence, StringWriter is no
CharSequence, so the call fails. Did you add such a method yourself? if
not, you need to convert to String first.
bye Jochen