{"id":1420,"date":"2010-08-02T18:00:46","date_gmt":"2010-08-02T12:30:46","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/2010\/08\/02\/unique-closure-on-more-than-one-field\/"},"modified":"2017-04-24T15:44:55","modified_gmt":"2017-04-24T10:14:55","slug":"unique-closure-on-more-than-one-field","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/unique-closure-on-more-than-one-field\/","title":{"rendered":"Unique closure on more than one field."},"content":{"rendered":"<p>In one of my <a title=\"Grails App Development\" href=\"http:\/\/www.tothenew.com\/grails-application-development\">recent grails project<\/a>, I had a requirement to get unique objects from a list based on more than one field. Now, this can be done by passing the list to closure unique.<\/p>\n<p>I had a list of dates of a couple of years, and what I needed was a unique combination of month and year.<\/p>\n<pre lang=\"groovy\"> \r\nList  dates \r\ndate.unique{[it.month,it.year]}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In one of my recent grails project, I had a requirement to get unique objects from a list based on more than one field. Now, this can be done by passing the list to closure unique. I had a list of dates of a couple of years, and what I needed was a unique combination [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2},"categories":[7],"tags":[358,4840,9,357],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1420"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=1420"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1420\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=1420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=1420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=1420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}