使用“$"在 Groovy 中 [英] Using "$" in Groovy

查看:35
本文介绍了使用“$"在 Groovy 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到 { } 用于闭包,然后我相信当 $ 放在大括号前面时,它只是在字符串中进行变量替换.我在参考中找不到关于 $ 如何工作的文档......不幸的是很难搜索它,并且 Groovy String 文档缺乏介绍这一点.您能否指出文档和/或解释 Groovy 中的$"运算符——如何使用它?Grails 是否将其扩展到 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?

推荐答案

在 GString(groovy 字符串)中,任何有效的 Groovy 表达式都可以包含在 ${...} 中,包括方法调用等.

In a GString (groovy string), any valid Groovy expression can be enclosed in the ${...} including method calls etc.

这在下一页中有详细说明.

这篇关于使用“$"在 Groovy 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆