Reputation: 16100
I'm reading an android gradle build file and I don't understand how some of it works from a syntax perspective and could do with some guidance. I've looked at the gradle and the groovy docs and can't find what I need. To be honest, I don't even know what to search for.
The structure in question is this:
name {
...
}
I suspect that it's something to do with closures, but I really don't know what's going on here. This structure is embedded in another identical structure. What are these things, and how are they invoked/read/used by the interpreter?
Upvotes: 1
Views: 60
Reputation: 37008
You are on the right track. This is a closure, that gets called as parameter to the method name
.
Like
name({ /*...*/ })
See the docs for when to leave out parentheses.
The method name
must not really exist in that context as this is a widely used pattern in groovy DSLs. methodMissing
will be called instead.
Upvotes: 2