unique « Intelligrape Groovy & Grails Blogs

Posts Tagged ‘ unique ’

Unique closure on more than one field.

Posted by Hitesh Bhatia on August 2nd, 2010

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
_________________________________

  • Share/Bookmark
Posted in Grails, Groovy