Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Closures in Groovy

 
Joe Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://groovy.codehaus.org/Closures

Referring to the link above, what big difference does a closure makes when we compare it with a normal function?
 
Josh Brown
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the link above:

"Closures may be 'bound' to variables within the scope where they are defined"

In addition to that, you can pass a closure as an argument to a method. Then that method can call your closure. This means you can give a method some block of code, and the method can execute that block of code.

I'd recommend reading the Formal Definition on the Groovy site.
[ April 10, 2008: Message edited by: Josh Brown ]
 
Joe Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, I got to understand this. Anyways, thanks for your reply!

Yesterday I bought the Groovy in Action book and started working on it already and it seems to be really interesting and now I'm fully exploring the Object Oriented concepts in Java through Groovy.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic