Groovy web console

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

ElvisTest

Published 2 weeks ago by Yohan
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def emptyArray = []
def shouldBeEmptyArray = emptyArray ?: [1, 2, 3]
shouldBeEmptyArray.each { println "${it}" }
 
def nullArray = null
def shouldBeNumbersArray = nullArray ?: [4, 5, 6]
shouldBeNumbersArray.each { println "${it}" }
 
def shouldDefinitlyBeEmpty = emptyArray == null ? [7, 8, 9] : emptyArray
shouldDefinitlyBeEmpty.each { println "${it}" }