-
Sep 20th, 2012, 04:54 PM
#1
"$action"(param1, param2) isn't working but method(param1, param2) does
So I am trying to avoid having a switch or bunch of if statements where I have a json request coming in and it has a property called action. That action is also the name of my closure method. But when I try using
"$jsonData.action"(params) I get an error
groovy.lang.MissingMethodException: No signature of method: GroovyScript.gameTableList() is applicable for argument types: (java.util.HashMap) values: [[action:gameTableList]]
but if I call the method with
gameTableList(params) it works.
Is there another way to dynamically call methods?
Thanks
Mark
-
Sep 21st, 2012, 03:32 PM
#2
The issue is that the methods/closures were defined as
def function = { params ->
}
By changing it to
def function(params) {
}
The code now works.
Mark
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules