Last active
June 2, 2017 02:47
-
-
Save houdq/339bcfd471d9e0a679e895b3ede459b6 to your computer and use it in GitHub Desktop.
Remove null items from a list in Groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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