Skip to content

Instantly share code, notes, and snippets.

@purplefox
Created April 4, 2012 12:46
Show Gist options
  • Save purplefox/2300852 to your computer and use it in GitHub Desktop.
Save purplefox/2300852 to your computer and use it in GitHub Desktop.
It's nice being able to set properties by passing them to the constructor in Groovy:
def foo = new Foo(bar: 23, wibble: "hello")
But if Foo is created via a factory method instead:
def foo = Foo.createFoo(bar: 23, wibble: "hello")
It doesn't work
where
class Foo {
.. properties
static Foo createFoo() {
return new Foo();
}
}
How can I get this to work with factories?
@pledbrook
Copy link

OK, I finally understand. You're right, you can't get automatic property binding once you're no longer using the default constructor. I've been told it may be worth a JIRA :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment