groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iisuru <>
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'} //calls invokemethod
p.test() //calls invokemethod

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


View this message in context:
Sent from the Groovy Users mailing list archive at

View raw message