David M. Karr (83) [Avatar] Offline
#1
Section 7.1.4 "Constructors" and subsection "Named Parameters" makes me wonder whether I can use named parameters in a constructor if I have an overloaded constructor that takes a single Map parameter. This is how it works with normal methods, but the text says that once you add an explicit constructor, named parameters are no longer available. If this is not the case, then the section should be a little more clear on this.
David M. Karr (83) [Avatar] Offline
#2
Re: 7.1.4. Constructors: Use named parameters with overloaded Map constructor?
To be a little more clear about my concern, consider the following class (I believe this is legal Groovy syntax):

Class Foo
{
private int foo1;
private int foo2;

Foo(int foo1, int foo2)
{
this.foo1 = foo1;
this.foo2 = foo2;
}
Foo(Map args)
{
this.foo1 = args.foo1;
this.foo2 = args.foo2;
}
}

Then:

Foo foo = new Foo(foo1:1, foo2:2);

Isn't this legal? The text of the section implies that it is not.