Hello, I'm having a problem while using constructors with a Groovy class.
I have a class Data
in a file called Data.groovy
with an inner class ContentEntry
. I want to initialize ContentEntry
instances from a Data
method:
static void initContent(nid, uid)
{
curContent = new ContentEntry()
curContent.nid = nid;
curContent.uid = uid;
}
with ContentEntry
defined as:
class ContentEntry
{
public int nid, uid
private tags = [:]
public ContentEntry()
{
}
ContentEntry(int nid, int uid)
{
this.nid = nid
this.uid = uid
}
//omitted rest of the class
But when running the project it gives me the following error:
Exception in thread "main" org.codehaus.groovy.runtime.metaclass.MethodSelectionException:
Could not find which method <init>() to invoke from this list:
public it.softit.Data$ContentEntry#<init>(it.softit.Data, int, int)
public it.softit.Data$ContentEntry#<init>(it.softit.Data)
It's like if constructors implicitly need an instance of the outer class passed as a parameter. I'm wondering why..