Groovy web console

subscribe to the feed Subscribe
to this
site

sublist and toarray

Published 1 month ago by Anonymous
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
def a = ['apple', 'banana', 'cherry']
println "${a.class} a: ${a.inspect()}"
println ""

//println "${a.class.methods}".replace(', ', '\n')

println "a.subList(0,1): ${a.subList(0,1).class} ${a.subList(0,1)}"
println "a.subList(1,2): ${a.subList(1,2).class} ${a.subList(1,2)}"
println "a.subList(2,3): ${a.subList(2,3).class} ${a.subList(2,3)}"

println ""
println "a.subList(2,3).toArray(): ${a.subList(2,3).toArray().class} ${a.subList(2,3).toArray()}"