Groovy web console

subscribe to the feed Subscribe
to this
Customer Accounts (via #groovywebconsole)
tweet this snippet Tweet

Customer Accounts

Published 1 year ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.transform.Canonical
@Canonical class Customer { List<Account> accounts }
@Canonical class Account { String number }

def getCustomers() {
        new Customer([ new Account("1"), new Account("2")]),
        new Customer([ new Account("3"), new Account("4")])

println getCustomers()*.accounts*.number.flatten()
// OR even
println getCustomers().accounts.number.flatten()