Groovy call() method

February 5, 2010

I'm using Groovy as a scripting language in a Java application. This allows us to change the behaviour of the interface at runtime without redeploying the code.

Today I was faced with the following error:

No signature of method: is applicable for argument types: ()

I was assuming this was something to do with the date parts of my code, for example bits that did:

def lToday = new Date()

I was considering giving up altogether and using Calendar, when I noticed the problem.

One of the variables of type date was referenced from the code with brackets after it:

if (lDate.before(lToday()))

This was trying to call the Date instance as a function, and that was what the error meant. The code should have been:

if (lDate.before(lToday))

Tags: groovy call