1
Closures is a Function in Groovy ? There is some difference between them?
1
Closures is a Function in Groovy ? There is some difference between them?
1
A function is something much simpler. A closure presupposes more things.
It certainly uses a function, but it needs to be first-order, meaning it needs to be able to be used as data, it can be used at any point where it makes sense, including storing in variables or passing as argument or function return.
But this would still only be an anonymous function, possibly with a syntax of lambda.
You still need to capture local variables from where it was defined and these variables need to be part of the enclosure function scope, even if it is used outside the scope where it was declared.
More can be seen in What is the difference between a lambda expression, a closure and a delegate?, despite being another language.
Browser other questions tagged function groovy grails closures
You are not signed in. Login or sign up in order to post.