Skip to main content

Blog Archive for mason during September 2006

If you are new to the concept, here's a refresher. Or if you prefer the layman's version: Let's say you want to have a lazily initialized singleton. Something like: public class Foo {    private static Foo _foo = null;        public static Foo getInstance() {        if (_foo = null) {     ...
Code block, in a nutshell, are basically just "lambda" functions (also known as closures in many other languages, most apropos might be Groovy) that are tied directly to a single method call. The canonical case is the way Ruby does array iterators: [1, 2, 3].each { |i| puts "the value is #{i}" } In this case the code block "{ |i| ... }" is passed to the method "each". This method calls...