Skip to content

Instantly share code, notes, and snippets.

@houdq
Last active June 2, 2017 02:47
Show Gist options
  • Save houdq/339bcfd471d9e0a679e895b3ede459b6 to your computer and use it in GitHub Desktop.
Save houdq/339bcfd471d9e0a679e895b3ede459b6 to your computer and use it in GitHub Desktop.
Remove null items from a list in Groovy
def list = []
class A {
String a
}
list.add(new A(a: "a"))
list.add(new A(a: "b"))
list.add(new A(a: null))
list.add(new A())
list.collect { it.a }.unique() - [null]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment