groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iisuru <iis...@gmail.com>
Subject MethodMissing Invoke method issue
Date Fri, 18 Aug 2017 18:05:37 GMT
Hi All,

Can u tell me how to use invokeMethod and methodMissing together on same
object.As per my observance invokeMethod invokes for both existing and none
existing methods..How to use both on same object so that available methods
to go to invoke method and others to route to methodmissing? 

class Person {
void work() {
println 'work'
}
}
def p = new Person()
p.metaClass.invokeMethod={String name,args -> println 'invokemethod'}
p.metaClass.methodmissing={String name,args-> println 'method mising'}
p.work() //calls invokemethod
p.test() //calls invokemethod

I want work() to goto invoke mehtod and test() to goto methodmissing.How to
do this?

Thanks
Isuru






--
View this message in context: http://groovy.329449.n5.nabble.com/MethodMissing-Invoke-method-issue-tp5742672.html
Sent from the Groovy Users mailing list archive at Nabble.com.

Mime
View raw message