File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Groovy and the fly likes strange grammar feature Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Other Languages » Groovy
Reply Bookmark "strange grammar feature" Watch "strange grammar feature" New topic
Author

strange grammar feature

bernard amadeus
Greenhorn

Joined: May 15, 2009
Posts: 21
Hello
(I'm a Groovy newbie)
by reading a groovy grammar (http://groovy.codehaus.org/jsr/spec/GroovyRecognizer.html#argument)
I do not understand the "argument" production
apparentlty there may be something like "*:" as a label .... seen nothing on the web to explain the meaning of that ...
any hint?
thanks
sergio ramirez
Greenhorn

Joined: Aug 28, 2011
Posts: 4

Hello Bernard!

Nice question!, *. operator is used to spread all elements in a list...

assert ['cat', 'elephant']*.size() == [3, 8]

while *: is used to spread or combine maps, so you could do something like this:

def argMap = [b:2, c:3, d:4]

fancyMethod(a:1, *:argMap) // You can see this complies the "argument" production in the groovy grammar

You could also see this link http://marc.info/?l=groovy-user&m=126217908601838

Hope this helps!
Regards,
Serch
 
IntelliJ Java IDE
 
subject: strange grammar feature
 
Threads others viewed
Incorect operations order when implementing math parser with JavaCC
Java
Why interpreter is the pattern?
Why Groovy?
Welcome Dierk Koenig
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture