Groovy benannte und Standardargumente

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Groovy benannte und Standardargumente

by Anonymous » 22 Aug 2025, 09:53

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?

Top