In one of my recent grails project, I had requirement to get unique objects from list based on more than one field. Now this can be done by passing list to closure unique .
I had list of dates of couple of years ,and what I needed was unique combination of month and year.
List<Date> dates date.unique{[it.month,it.year]}
_________________________________
Hitesh Bhatia
Mail
LinkedIn,Facebook,Twitter
_________________________________
This entry was posted
on August 2nd, 2010
at
6:00 pm and is filed under
Grails, Groovy .
You can follow any responses to this entry through the
RSS 2.0 feed.
You can leave a response, or trackback from your own site.

Hi Hitesh,
That’s really helpful post. Unless we used to take TreeSet to avoid duplication.
Thanks for this valuable concept.
Regards,
Subrata
Hi Subrata
yes ..that would have been good alternative ..
Thnx