开发者

Hows the syntax to getProperty dynamically?

开发者 https://www.devze.com 2022-12-17 02:53 出处:网络
Is thi开发者_如何学运维s possible and if, how? item.foo = \"moo\" def x = \"foo\" item.[x] = \"moo\"

Is thi开发者_如何学运维s possible and if, how?

item.foo = "moo"

def x = "foo"
item.[x] = "moo"


I'm not sure I get your question, but...

def item = {
    def foo
}
def x = "foo"
item[x] = "moo"

assert item[x] == "moo"
assert item.foo == "moo"
0

精彩评论

暂无评论...
验证码 换一张
取 消