Scott,
Hello again - it's Trevor Butler from SAS. I enjoyed your last class here on
Java 5, and at the end, you brought up Groovy and gave us an introduction.
I recently had the need to perform a search and replace on a text file to automate some
testing I am doing, so I loaded up the Groovy jar and got to work. In combing through the codehaus site and a Groovy book a colleague had, I was fascinated by closures. Coming from Java, most of the Groovy language made sense either as a simpler syntax or shorthand. However, closures were different.
I have never used any other language that had closures, and it took me a while to get the hang of them. I still am not entirely comfortable with them beyond basic for-each type looping scenarios.
Since I found closures to require a paradigm shift in thinking, I am guessing other folks coming from Java and other static OO languages might feel the same.
Question: How would you describe closures to a person such as myself who comes from a Java / static OO / procedural language world in such a way that they can grasp the concept?
Thanks,
Trevor