March 16, 2010

Groovy intro: range operator and looping

The operator .. in Groovy is called the range operator, not the dot-dot operator or two-dot operator. It's used to define ranges for things like loops; for(1..8){foo()} will loop eight times.

Ref: http://groovy.codehaus.org/Collections#Collections-Ranges

New Groovy-style loops are a little more powerful than Java loops, too:
http://groovy.codehaus.org/Looping

No comments:

Post a Comment