On Sunday 28 March 2010 01:26:05, Adam Murdoch wrote:
> On 27/03/10 5:26 PM, Geronimo M. H. wrote:
> > On Friday 26 March 2010 14:06:41, Geronimo M. H. wrote:
> >> How can I define the map, so that the keys of the map are the values and
> >> not the names of the defined keys (from above)?
> >
> > I moved the map creation into a constructor
> >
> >     def targetSubDir = [:]
> >
> >     SRProjectTypes() {
> >        targetSubDir[LibraryType]     = 'lib'
> >        targetSubDir[ProcessType]     = 'ext'
> >        targetSubDir[ServiceType]     = 'srv'
> >        targetSubDir[ApplicationType] = 'ext'
> >        targetSubDir[ThemeType]       = 'ext'
> >        targetSubDir[StandaloneType]  = '.'
> >     }
>
> targetSubDir = [:]
> targetSubDir[LibraryType] = '..'
>
> will use LibraryType as the key, whereas
>
> targetSubDir = [LibraryType: '...']
>
> will use 'LibraryType' as the key (ie the string 'LibraryType')
>
> This is a Groovy behaviour. But I guess it is an example of where
> learning Groovy and Gradle at the same time can be a bit confusing.

Yes, but after the error I already guessed that behaviour. The latter form is 
used be gradle and through out the groovy userguide and I did not know, wich 
words to search for, to find a groovy solution for the former variant.
So I searched for groovy tutorials from other sites that explained 
initialization of maps...

Using java, I would declare the map as "static final" and place the 
initialization in the "static { }" closure. I wonder, how this will be coded 
with groovy.

I was very astonished, that the constructor (without args) got executed, 
although I use the constructor with map-arguments.

After all, I learned a bit :)

Thank you for your assistance!

kind regards

Geronimo

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to