标签: groovy dynamic getproperty
这是可能的,如果,如何?
item.foo = "moo" def x = "foo" item.[x] = "moo"
答案 0 :(得分:0)
我不确定我是否接受了你的问题,但是......
def item = { def foo } def x = "foo" item[x] = "moo" assert item[x] == "moo" assert item.foo == "moo"