groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paolo Piersanti <pa...@micso.it>
Subject closure calls routing
Date Thu, 25 Jun 2015 20:15:24 GMT
For sure I misunderstood something about how closure calls are routed.


For instance in groovy version 2.4.2:
<----------
target = 'aTarget'
c = new GroovyShell().evaluate("{ -> leftShift('*') }");
c.resolveStrategy = Closure.DELEGATE_ONLY
c.delegate = target
c.call()
----------->

the result is how expected:

aTarget*

but if I change the strategy to:
c.resolveStrategy = Closure.DELEGATE_FIRST

the result is:
Exception thrown

groovy.lang.MissingMethodException: No signature of method:
Script1$_run_closure1.doCall() is applicable for argument types:
(java.lang.String) values: [*]
Possible solutions: doCall(), findAll(), findAll(),
isCase(java.lang.Object), isCase(java.lang.Object)
	at Script1$_run_closure1.doCall(Script1.groovy:1)
	at ConsoleScript33.run(ConsoleScript33:5)

Shouldn't the delegate (target string) be looked up first and used ?

Thank You in advance
Paolo Piersanti


-- 
    Signature for Rent - Questo spazio si affitta
Paolo Piersanti  Software Developer & System Admininistrator



Mime
View raw message