使用“$”在Groovy [英] Using "$" in Groovy
问题描述
我看{}用于闭包,然后我相信当$放在大括号的前面时,它只是在一个字符串内进行变量替换。我找不到有关如何在引用中工作的文档...很难在其上进行搜索,并且Groovy String文档缺乏介绍。您能否指点我的文档和/或解释Groovy中的$操作符 - 它如何使用? Grails在Groovy之外是否扩展它?
在GString(groovy字符串)中,任何有效的Groovy表达式都可以包含在$ {...}包括方法调用等。
这在关注页面。
I see { } are used for closures, and then I believe when a $ is put in front of braces, it is simply doing a variable substitution within a string. I can't find the documentation on how the $ works in the reference ... hard to search on it unfortunately, and the Groovy String documentation is lacking in introducing this. Can you please point me to the documentation and/or explain the "$" operator in Groovy -- how all it can be used? Does Grails extend it at all beyond Groovy?
In a GString (groovy string), any valid Groovy expression can be enclosed in the ${...} including method calls etc.
This is detailed in the following page.
这篇关于使用“$”在Groovy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!