Groovy web console

subscribe to the feed Subscribe
to this
site
collection null or empty (via #groovywebconsole)
tweet this snippet Tweet
this
script

collection null or empty

Published 1 month ago by Gabriel Bianchi with tags collection null empty
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
Collection a = null

if (a) {
    println "a is not null"
} else {
    println "a is null or empty"
}
a = []
if (a) {
    println "a is not null"
} else {
    println "a is null or empty"
}
a = [1,2]
if (a) {
    println "a is not null"
} else {
    println "a is null or empty"
}