I have a collection of ID list to be saved into the database
if(!session.ids) session.ids = [] session.ids.add(params.id)
and I found out that list has duplicates, like
[1, 2, 4, 9, 7, 10, 8, 6, 6, 5]
Then I wanted to remove all duplicates by applying something like :
session.ids.removeAll{ //some clousure case }
I found only this:
http://groovy.codehaus.org/groovy-jdk/java/util/Collection.html
I am not a Groovy person , but I believe you can do something like this :
[1, 2, 4, 9, 7, 10, 8, 6, 6, 5].unique { a, b -> a <=> b }
Have you tried session.ids.unique() ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With