enum Seasons { SPRING, SUMMER, FALL, WINTER }
println "All seasons"
Seasons.each { println it }
println "\nJust a few seasons"
(Seasons.SPRING..Seasons.FALL).each { println it }
--
Guillaume Laforge
Groovy Project Manager
G2One, Inc. Vice-President Technology
http://www.g2one.com
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
this works for me from the command line with groovy 1.5.5, but fails
in eclipse which has the plugin
org.codehaus.groovy.eclipse.ui_1.5.1.200801232227.jar. i get the: "
... No signature of method: Seasons.next() is applicable for argument
types: () values: {} ... "
thanks
> <<mailto:pthib...@yahoo.ca>pthib...@yahoo.ca>
> > <http://www.g2one.com>http://www.g2one.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list, please visit:
> >
> >
> <http://xircles.codehaus.org/manage_email>http://xircles.codehaus.org/manage_email
> >
> >
> >
> > ________________________________
> > Be smarter than spam. See how smart SpamGuard is at giving junk email the
> > boot with the All-new Yahoo! Mail
> > ________________________________
> > Looking for the perfect gift? Give the gift of Flickr!
>
>
>
>--
>Guillaume Laforge
>Groovy Project Manager
>G2One, Inc. Vice-President Technology
><http://www.g2one.com>http://www.g2one.com
>
>---------------------------------------------------------------------
>To unsubscribe from this list, please visit:
>
>
><http://xircles.codehaus.org/manage_email>http://xircles.codehaus.org/manage_email
>
>
>
>
>Be smarter than spam. See how smart SpamGuard is at giving junk
>email the boot with the
><http://ca.promos.yahoo.com/newmail/overview2/>All-new Yahoo! Mail
---
vice-chair http://ocjug.org/
I have a map that takes a string as key and an ArrayList as value. The
arraylist contains a list of strings.
if(documentMap."$theWord")
{
(documentMap."$theWord").add(processedLine)
}
else
{
ArrayList textList = new ArrayList();
textList.add(processedLine);
documentMap.put(theWord,textList);
}
The q is, can I do it in one line? At least the else part?
Something like
documentMap[theWord] = (documentMap.get[theWord,new
ArrayList().add(processedLine)])
Where the "get" method will put in a "default" value for the ArrayList
the very first time and next time onwards it will just add values to the
arraylist.
Thanks,
Abraham.
Please do not print this email unless it is absolutely necessary.
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
I have a method like this... and it is called get ;)
documentMap.get(theWord,[processedLine])
a few comments:
* [processedLine] will create an ArrayList and add the claues in []
* documentMap."$theWord" will use a GString to lookup the key in the
map, but GStrings are not totally equal to String, better don't use them
as key for storing or getting values.
bye blackdrag
--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/
http://www.g2one.com/
Thank You! This works beautifully.
Now my code reads like
documentMap[theWord] ? (documentMap.get(theWord)).add(processedLine) :
documentMap.get(theWord,[processedLine])
With no messy array initializations!! And its all in one line...:D
Thanks,
Abraham
documentMap.get(theWord,[processedLine])
bye blackdrag
http://xircles.codehaus.org/manage_email
Please do not print this email unless it is absolutely necessary.
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
---------------------------------------------------------------------