Groovy web console

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

TestingOutGroovy

Published 6 months ago by Ashley with tags testing
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class App {
   static class Address {
        String location

        String toString() { return location }
   }
   static class Person {
        String name
        Address address

        def friends = []
        def enemies = [:]
   }

   static void main(String[] args) {

        App.Person person = new App.Person();
        App.Address address = new App.Address();

        address.location = 'Coolio st qld'
        person.address = address

        person.friends << 'cody'
        person.friends << 'mal'
        person.friends << 'alice'

        person.enemies.put('worst', 'enemy1')
        person.enemies.put('medium', 'enemy2')
        person.enemies.put('fave', 'voldemort')

        println '===Address==='
        println person.address

        println '===Friends==='
        person.friends.each{ println it }

        println '===Enemies==='
        person.enemies.each { println it.key + ' : ' + it.value}
    }

}