是否可以将字符串计算为 groovy 中的变量?
我正在玩 grails 和 groovy。我想知道是否可以做这样的事情。
def inbuiltReqAttributes = ['actionName','actionUri','controllerName','controllerUri']
inbuiltReqAttributes.each() { print " ${it} = ? " };
我会在里面放什么?让groovy将当前迭代器值作为变量进行评估,例如,长期这样做
print " actionName = $actionName "
谢谢
I am playing with grails and groovy. I wondered if its possible to do something like this.
def inbuiltReqAttributes = ['actionName','actionUri','controllerName','controllerUri']
inbuiltReqAttributes.each() { print " ${it} = ? " };
what would i put in the ? to get groovy to evaluate the current iterator value as a variable e.g. to do it the long way
print " actionName = $actionName "
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信我的头脑中,这应该有效:
或者:
但我不在计算机上 100% 验证这个 atm...
I believe off the top of my head, this should work:
Or:
But i'm not at a computer to 100% verify this atm...
试试这个:
Try this: