tag:blogger.com,1999:blog-7290642316743338665.post4821278400691686886..comments2023-09-20T05:23:44.886-05:00Comments on behind the times: Fun with Groovy Closures: Variable ScopeHamlet D'Arcyhttp://www.blogger.com/profile/04008870357169725586noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-7290642316743338665.post-14603972738776312412009-03-09T00:23:00.000-05:002009-03-09T00:23:00.000-05:00For the final workaround(by using curry), in fact,...For the final workaround(by using curry), in fact, curry is NOT the key to solving the issue:<BR/>class Utility5 <BR/>{<BR/> def run = { closure -><BR/> def x = 1<BR/> 3.times {closure.call(x++)}<BR/> }<BR/>}<BR/>new Utility5().run {println it}Happy coderhttps://www.blogger.com/profile/13577021101412474582noreply@blogger.comtag:blogger.com,1999:blog-7290642316743338665.post-20481349823112887162007-11-10T01:17:00.001-06:002007-11-10T01:17:00.001-06:00buttsmcgeee? WTF? My sister-in-law must have got...buttsmcgeee? WTF? My sister-in-law must have gotten in and screwed with my blogger account...Robert Fischerhttps://www.blogger.com/profile/17844778275497805797noreply@blogger.comtag:blogger.com,1999:blog-7290642316743338665.post-7510555186478824422007-11-10T01:17:00.000-06:002007-11-10T01:17:00.000-06:00In Java, you can reference a variable from within ...In Java, you can reference a variable from within an inner class if the variable is declared "final" (which, of course, you should be doing 95%+ of the time, anyway*).<BR/><BR/>* See: http://enfranchisedmind.com/blog/2007/01/11/yet-another-reason-final-is-your-friend/<BR/>http://enfranchisedmind.com/blog/2006/02/08/object-burn-is-your-friend/Robert Fischerhttps://www.blogger.com/profile/17844778275497805797noreply@blogger.com