As stated, there is no shortcut in Groovy. But if you want/need this
syntax, you can achieve this with Groovy
Macros.
E.g. a very straight forward attempt:
@Macro
static Expression map(MacroContext ctx, final Expression... exps) {
return new MapExpression(
exps.collect{
new MapEntryExpression(GeneralUtils.constX(it.getText()), it)
}
)
}
Usage:
def a = 42
def b = 666
println(map(a,b))
// → [a:42, b:666]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…