Hi, you've reached the website of Mark Menard, Freemason, developer, businessman, photographer, motorcyclist and all around nice guy.
The main joy in my life is Sylva, my loving partner and friend. (You will see plenty of pictures of her. Also check out our site.) My professonal career is running a consulting firm concentrating on business automation and custom software. I enjoy software development, motorcycles, photography, dancing, freemasonry and travel.
Here you will find galleries of my latest photos, thoughts on software development, freemasonry, the occassional politics, and other things. Enjoy your time here.
Mark
An ongoing photographic study of Freemasonry.
To contact Mark send an email to mark@mjm.net. You will receive an auto response from my mail server to verify you're not a spammer.
© Mark Menard 2002-2007
Closures and Bindings in Groovy: Question
Great blog post about closure. But it reminds me that I red stuffs like this in "Groovy in Action". By the way, there is still something I don't get: the following programm
Vector myArray = new Vector()
int i = 0
0.upto(2) {
myArray.add( {println "Current i is:"+i} )
i++
}
for ( clos in myArray )
clos.call()
has the following output:
Current i is:3
Current i is:3
Current i is:3
and using the Binding you talk about:
Vector myArray = new Vector()
0.upto(2) {
def clos = {println "Current value is:" + this.it}
def binding = new Binding ()
binding.setVariable ("it", it)
clos.setBinding (binding)
myArray.add( clos )
}
for ( clos in myArray )
clos.call()
has the result:
Current value is:2
Current value is:2
Current value is:2
I don't get how to associate data to a closure...