Skip to content

Instantly share code, notes, and snippets.

@peysal
Last active December 21, 2015 13:49
Show Gist options
  • Save peysal/6315154 to your computer and use it in GitHub Desktop.
Save peysal/6315154 to your computer and use it in GitHub Desktop.
Groovy introduction: 1) no accessors method 2) gString 3) accessing object 4) equality operator not referring to memory address extra: can change the value to make wrong assertion just to show groovy trace
class Person {
String name
int age
}
//no accessors method
Person person = new Person()
person.name = "goku"
println "helloo ${person.name}"
assert person.name == "goku"
assert person["name"] == "goku"
person = new Person(name:"gohan") //passing constructor value
assert person.name == "gohan"
println "helloo ${person.name}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment