Skip to content

Instantly share code, notes, and snippets.

@peysal
Created August 23, 2013 04:13
Show Gist options
  • Save peysal/6315473 to your computer and use it in GitHub Desktop.
Save peysal/6315473 to your computer and use it in GitHub Desktop.
Introduction to groovy 1) duck typing 2) return is optional, last statement will be taken
class Person {
def name //duck typing
def age
def getName() { //override default getter
"will not be printed"
"my name is ${name}" //return is optional, last statement is taken
}
}
person = new Person(name:"goku")
println "hello " + person.name
assert "hello " + person.name == "hello my name is goku"
assert "hello " + person.name == "hello ${person.name}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment