Gradle单对双引号 [英] Gradle Single vs Double Quotes

查看:342
本文介绍了Gradle单对双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对gradle很陌生,现在只是试图按照教程进行操作,并且我看过很多次我看过单引号和双引号混合使用。我只是想知道在一套应该用于另一套时是否有差异。其中一个例子是教程的第6.12节 - 默认任务

I'm new to gradle and am currently just trying to follow the tutorials and quite a few times I've seen single and double quotes intermixed. I just wanted to know if there was a difference of when one set should be used over the other. One example of this is section 6.12 of the tutorial - Default tasks:

defaultTasks 'clean', 'run'

task clean << {
    println 'Default Cleaning!'
}

task run << {
    println 'Default Running!'
}

task other << {
    println "I'm not a default task!"
}

所以,我只想知道我是否应该关注这些差异或者它们是可互换的,并且我可以在gradle中打印字符串时使用单引号或双引号。

So, I would just like to know if I should be paying attention to these differences or if they are inter-changable and I can use either single or double quotes when printing strings in gradle.

推荐答案

Gradle构建脚本是用Groovy编写的。 Groovy有双引号和单引号的字符串。主要区别在于双引号的字符串支持字符串插值:

Gradle build scripts are written in Groovy. Groovy has both double-quoted and single-quoted String literals. The main difference is that double-quoted String literals support String interpolation:

def x = 10
println "result is $x" // prints: result is 10

您可以在 或其他Groovy文章。

You can learn more about Groovy String interpolation in this or other Groovy articles on the web.

这篇关于Gradle单对双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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