Groovy web console

subscribe to the feed Subscribe
to this
site
Groovy Safe Navigation and String check (via #groovywebconsole)
tweet this snippet Tweet
this
script

Groovy Safe Navigation and String check

Published 1 month ago by Hardik Modha with tags groovy string safe navigation
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
['', '   ', null, 'test'].each { String string ->
    if (string?.trim()) {
      println "string is not empty"
    } else {
       println "string is empty/null"
    }
}