Groovy 什么';${foo}和#{bar}之间的区别是什么?
字符串占位符中的Groovy 什么';${foo}和#{bar}之间的区别是什么?,groovy,Groovy,字符串占位符中的${foo}和{bar}之间有什么区别?{}不是一个简单的groovy构造,它不会被计算 def foo = 1 def bar = 2 println "${foo} and #{bar}" 返回 1 and #{bar} 也许它与Ruby和/或Coffeescript自己的字符串插值混合在一起 红宝石: : Groovy使用${}表示法,需要使用双引号或三重双引号声明字符串: groovy:000> a = "bar" ===> bar groovy:0
${foo}
和{bar}
之间有什么区别?{}
不是一个简单的groovy构造,它不会被计算
def foo = 1
def bar = 2
println "${foo} and #{bar}"
返回
1 and #{bar}
也许它与Ruby和/或Coffeescript自己的字符串插值混合在一起 红宝石: :
Groovy使用
${}
表示法,需要使用双引号或三重双引号声明字符串:
groovy:000> a = "bar"
===> bar
groovy:000> """to the $a"""
===> to the bar
groovy:000> "to the ${a}"
===> to the bar
或是一根粗线,或是一美元粗线。
a = "coffee"
alert "i'd love some #{a}"
groovy:000> a = "bar"
===> bar
groovy:000> """to the $a"""
===> to the bar
groovy:000> "to the ${a}"
===> to the bar