Groovy benannte und StandardargumenteJava

Java-Forum
Anonymous
 Groovy benannte und Standardargumente

Post by Anonymous »

Groovy unterstützt sowohl Standard als auch benannte Argumente. Ich sehe sie einfach nicht zusammenarbeiten.def a1 = new A(2)
def a2 = new A(a: 200, b: "non default")

class A extends SomeBase {
def props
A(a=1, b="str") {
_init(a, b)
}

A(args) {
// use the values in the args map:
_init(args.a, args.b)
props = args
}

private _init(a, b) {
}

}
< /code>

Ist es im Allgemeinen eine gute Praxis, beide gleichzeitig zu unterstützen? Ist der obige Code der einzige Weg dazu?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post