Groovy web console

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

Groovy List Weirdness

Published 2 months ago by Stefan Freyr
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def version = "5.25"
def extraTags = 'foo,bar'

// prints out [foo, bar]
println ( extraTags == null ? [] : extraTags.split(',') )

// prints out [5.25, [foo, bar]]
println ( [version] + extraTags.split(',') )

// prints out [5.25, foo, bar]
println ( [version] + ['foo', 'bar'] )