Groovy web console

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

CheckElvis

Published 7 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 = emptyArray == null ? [1, 2, 3] : emptyArray
shouldDefinitlyBeEmpty.each { println "${it}" }