Wednesday, September 19, 2012

Groovy closure composition

Two different ways to compose closures in Groovy:

2 comments:

  1. Hi Manuel,
    Good post. I like your approach: to compare two different ways of writing closure composition. This way it is easier to understand groovy specific syntax for this.
    Please allow me to mention one drawback of your examples: they produce different results. First example produces 15 25 35 45 55, while second example produces 60 70 80 90 100.
    May I suggest little correction:
    - when plusFive and timesTen are swapped in the second example, so that statement looks like:

    def doAll = timesTen >> plusFive >> print

    then the example produces 15 25 35 45 55.

    ReplyDelete