Announcement Announcement Module
Collapse
No announcement yet.
"$action"(param1, param2) isn't working but method(param1, param2) does Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • "$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

  • #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

    Comment

    Working...
    X