![]() ![]() ( closure, anyone?) executed against various objects: There are three main script files that Gradle uses. You can read more about delegation and delegation strategies in Groovy documentation. There’s actually a bit more to delegates and how closure’s statements are executed. We will see later why this is crucial in Gradle. We can see that printClosure calls printText method on the delegate it is provided (the same goes for properties). What’s different is that we can change the delegate of a closure. They’re blocks of code that can be executed, can have parameters, and return values. ![]() If you’re familiar with Kotlin, you might find below explanation somewhat similar to function literals with receiver.Ĭlosures in Groovy can be thought of as lambdas on steroids. ![]() One important feature that needs some explaining are closures. Mind that in both cases the result will be the same regardless of parameters order! Also notice omitted parentheses in both calls. This will print "John is 24 years old" followed by John works as Android developer at Tooploox. Other (non-named arguments) are then appended to parameters list:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |