Very basic question.
This snapshot in build.gradle
:
dependencies {
classpath 'com.android.tools.build:gradle:0.13.2'
}
is supposed to call method dependencies(Closure c)
and pass it a closure.
Could someone please explain the syntax of this simple closure { classpath 'com.android.tools.build:gradle:0.13.2' }
It is not returning anything, is it ?
http://groovy.codehaus.org/Closures+-+Formal+Definition
Notably:
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 (eg an explicit return statement is optional).
There's not really any syntax to explain; there's a closure, inside it the classpath
method is called, and it takes a string argument. Whether or not anything is done with the return value, or whether or not the return value is significant , is a separate issue.
In this case it's not; there's a side-effect of setting the classpath value.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.