aspose file tools*
The moose likes Groovy and the fly likes GPath spread operator (*.) and another GinA example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "GPath spread operator (*.) and another GinA example" Watch "GPath spread operator (*.) and another GinA example" New topic
Author

GPath spread operator (*.) and another GinA example

Kristian Jones
Greenhorn

Joined: Jun 26, 2008
Posts: 6
Hello again.
I'm slowly getting there with groovy and working through the example listings in GinA but this time I think I really have found an example that doesn't work with the latest version.

Listing : 7.23


I'm guessing this doesn't work because GinA assumes 1.0 and I'm on 1.6.5.

I found this bug http://jira.codehaus.org/browse/GROOVY-2387 which recommends replacing the last line with


An obvious question is where did sum() come from?

Can anyone explain how I should be using spread (*.) operator in the later version of groovy as it seems like a really powerful feature

My final question is, are there many of these gotchas in the groovy GDK which newbies should be aware of ?

Kris
Kristian Jones
Greenhorn

Joined: Jun 26, 2008
Posts: 6
Found the following on the authors website : http://www.manning-sandbox.com/thread.jspa?threadID=33351&tstart=0

.flattern() works too.
Dave Klein
author
Ranch Hand

Joined: Aug 29, 2007
Posts: 77
sum() is a method on Collection after it's been enhanced by the GDK. It was there in 1.0 but new over-ridden versions were included in 1.5 and above. You can read more about it and find many other hiddend Groovy nuggets in the GDK docs: http://groovy.codehaus.org/groovy-jdk. This doc will show you all the nifty features added to JDK classes / interfaces.

Have fun!
Dave


Author of Grails: A Quick-Start Guide
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: GPath spread operator (*.) and another GinA example