Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GPath spread operator (*.) and another GinA example

 
Kristian Jones
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic