Working with Ranges

Using ranges, you can conveniently creates lists of sequential values. If you need to work with a list of integers from 1 to 100, rather than creating a list with 100 literal numbers in it, you can use ..:

def indexes = 1..100

The range is particularly useful in performing iterations over a list of items in combination with a for loop like this:

def indexes = 1..100
for (j in indexes) {
  // do something with j here
}

Of course, you need not assign the range to a variable to use it in a loop, you can use it inline like this:

for (j in 1..100) {
  // do something with j here
}