Closures - Groovin' with Groovy
class Point {
    x
    y
    Point(x,y) { this.x = x; this.y = y }
    eachCoordinate(closure) {
        closure.call(x)
        closure.call(y)
    }
}

p = new Point(10, 20)

counter = 0
p.eachCoordinate { counter += 1 }
println "The point has ${counter} dimensions"

[Example 10 Output]

Example 10