This might be useful:
listOfMaps.groupBy{ it.id }
// => [1:[[id:1, name:joe], [id:1, name:steve]], 2:[[id:2, name:bob]]]
Cheers, Paul.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
def listOfMaps =
[[id:"1",name:"joe"],[id:"2",name:"bob"],[id:"1",name:"steve"]]
def keyList = listOfMaps.collect { it.id } .unique()
// OR
def keySet = listOfMaps.collect { it.id } as Set
Cheers,
Peter
--
View this message in context: http://old.nabble.com/list-of-maps%2C-is-there-a-way-to-get-unique-tp28115650p28121029.html
Sent from the groovy - user mailing list archive at Nabble.com.
As project lead, I'd like to publicly say we're against skinning cats, and that no animals were harmed in the process of building the Groovy project :-)
def listOfMaps = [[id:"1",name:"joe"],[id:"2",name:"bob"],[id:"1",name:"steve"]]
listOfMaps.id == [1,2,1] // herelistOfMaps.id.unique() = [1,2]
Cheers,
Peter
Moe-25 wrote:
>
> def listOfMaps =
> [[id:"1",name:"joe"],[id:"2",name:"bob"],[id:"1",name:"steve"]]
>
> listOfMaps.id == [1,2,1] // here
>
> listOfMaps.id.unique() = [1,2]
>
> What method is used to accomplish that behind the curtain? Is it groupBy ?
>
--
View this message in context: http://old.nabble.com/list-of-maps%2C-is-there-a-way-to-get-unique-tp28115650p28126715.html