Groovy web console

subscribe to the feed Subscribe
to this
site

Groovy Hello

Published 3 months ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class speaker {
    def printLn(String string) {
        println string
    }
}

def talk = new speaker()
// you don't always need a def 

def helloText = "Hello in Groovy"
println "Hello Text:"
talk.printLn(helloText)

def helloArray=["Hello 1!","Hello 2!"]
println "Hello Array:"
helloArray.each { talk.printLn(it) }