Groovy web console

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

ElvisCheckEkino

Published 10 months 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 ?: [1, 2, 3]
shouldBeNumbersArray.each { println "${it}" }

def shouldDefinitlyBeEmpty
if (emptyArray != null)
    shouldDefinitlyBeEmpty = emptyArray
else
    shouldDefinitlyBeEmpty = [1, 2, 3]
shouldDefinitlyBeEmpty.each { println "${it}" }