gpt4 book ai didi

grails - 可以将字符串评估为groovy中的变量吗?

转载 作者:行者123 更新时间:2023-12-02 14:09:13 25 4
gpt4 key购买 nike

我在玩grails和groovy。我想知道是否可以做这样的事情。

def inbuiltReqAttributes = ['actionName','actionUri','controllerName','controllerUri']
inbuiltReqAttributes.each() { print " ${it} = ? " };

我要放什么? groovy将当前迭代器值评估为变量,例如长远地做
print " actionName = $actionName "

谢谢

最佳答案

我认为,这应该起作用:

print " ${it} = ${this[ it ]}"

要么:
print " ${it} = ${getProperty( it )}"

但是我不是在计算机上100%验证此atm ...

关于grails - 可以将字符串评估为groovy中的变量吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7867081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com