URL: http://hansamann.podspot.de/files/grails_podcast_episode_35.mp3
This snippet gives you some interesting examples what you can do with Groovy Ranges. Listen to the audio to get the best learning experience. Simply right-click on the title above to download the mp3 file of this part of the series.
The Groovy Series is part of the Grails Podcast and can be subscribed to via: http://hansamann.podspot.de/rss. The series is produced by Dierk König and Sven Haiges, further information about the topic of this episode can be found in the book
Groovy in Action - http://groovy.canoo.com/gina
//Ranges //inclusive range def inclusiveRange = 1..10 //exclusive range //sequence from negative to positive values //negative sequence //we need no for loop :-) //but don't forget the braces around the range... out << it } //but we can use a for loop if we want def range = 1..10 out << i } //we can also step through a range //some more fun with groovy //using ranges to create a sublist //ranges can be used with grep... here using grep with a list
Comments
Subscribe to comments
You need to login to post a comment.

Nice example and accompanying podcast. I started out thinking 'Ranges' are simple, but now they seem a bit confusing. I think I will have to revisit this topic in some time again.