Last active
December 21, 2015 13:49
-
-
Save peysal/6315293 to your computer and use it in GitHub Desktop.
Groovy introduction: 1) list
2) operator overloading
3) method pointer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def list = [] | |
assert list.isEmpty() | |
list.add("ayam") | |
list.add "babun" //optional parentheses, except if it doesnt have any argument | |
list << "cicak" //operator overloading | |
assert list.size == 3 | |
println list | |
def tambah = list.&add //method pointer in action | |
tambah "dugong" | |
println list | |
assert list.size == 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment