非常基本的问题。
这个快照在build.gradle
中:
dependencies {
classpath 'com.android.tools.build:gradle:0.13.2'
}
应该调用方法
dependencies(Closure c)
并将其传递给闭包。有人可以解释一下这个简单闭包的语法
{ classpath 'com.android.tools.build:gradle:0.13.2' }
它没有返回任何东西,是吗?
最佳答案
http://groovy.codehaus.org/Closures+-+Formal+Definition
值得注意的是:
Closures always return a value. This may occur via either an explicit return statement, or as the value of the last statement in the closure body (e.g. an explicit return statement is optional).
确实没有任何语法可以解释。有一个闭包,其中调用了
classpath
方法,它带有一个字符串参数。是否对返回值进行任何操作,或者返回值是否有意义,是一个单独的问题。在这种情况下不是这样。设置类路径值会有副作用。
关于android - Gradle依赖项Groovy关闭语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27040165/