Published in: Groovy
URL: http://hansamann.podspot.de/files/grails_podcast_episode_37.mp3
This snippet gives you some interesting examples what you can do with Groovy Maps. 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
//keys are Strings by default //you must use parentheses if a variable should become a key //you can use array-style notation or bean-style notation to access and set entries //array-style map['a'] = 1 //bean-style map.b = 2 //using a default value in case the key is not available //iterating over a map with each() -> "it" is an entry with properties key and value //or split the entry into key and value directly //get all keys of a map //you can use findAll with maps, too 'Dierk Koenig':'Groovy in Action'] //and collect... collect does a transformation with each entry
Comments
Subscribe to comments
You need to login to post a comment.

So close! The last line is actually: assert list.join(',') == 'The Definitive Guide to Grails,GINA' Thanks for the snippets though :)
So close! The last line is actually: assert list.join(',') == 'The Definitive Guide to Grails,GINA' Thanks for the snippets though :)