Groovy web console

subscribe to the feed Subscribe
to this
site
Checking blank strings (via #groovywebconsole)
tweet this snippet Tweet
this
script

Checking blank strings

Published 2 months ago by Laura with tags string blank
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def blankString = ""
def emptyString = null
def nonEmptyString = "test"

if (blankString){
    println "I'm not testing empty strings."
} else {
    println "This string is BLANK."
}

if (emptyString) {
    println "I'm not testing empty strings."
} else {
    println "This string is EMPTY."
}

if ( nonEmptyString ) {
    println "Non empty string."
} else {
    println "I don't recognize non empty string."
}