Skip to content

Instantly share code, notes, and snippets.

@mangei
Created April 22, 2014 08:03
Show Gist options
  • Save mangei/11169410 to your computer and use it in GitHub Desktop.
Save mangei/11169410 to your computer and use it in GitHub Desktop.
emptyList check in Groovy
package io.geier
class IfTest {
public static void main(String[] args) {
List<String> emptyList = null;
if (emptyList == null || emptyList.empty) {
// return []
println "AAA"
}
if (emptyList?.empty) {
// return []
println "BBB"
}
println "CCC"
}
}
//
// OUTPUT:
// AAA
// CCC
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment