Saturday, January 30, 2010

Groovy operations

This is so cool:
If you have two lists and want to subtract one list from another:
myList = myList - yourList // requires that both lists have same type of elements.


Intersection
userIds.intersect(usersWithPermissions)


Split a name-value pair string to make it a String[]
String [] pair = someString.split(":") // now pair[0] = key and pair[1] = value
split() uses regex so escape any special char e.g. split("\\|") to split("|")

No comments: