diff options
-rw-r--r-- | groovy.html.markdown | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/groovy.html.markdown b/groovy.html.markdown index e440ef00..63cef76b 100644 --- a/groovy.html.markdown +++ b/groovy.html.markdown @@ -54,15 +54,26 @@ println x //Creating an empty list def technologies = [] -//Add an element to the list -technologies << "Groovy" +/*** Adding a elements to the list ***/ + +// As with Java technologies.add("Grails") + +// Left shift adds, and returns the list +technologies << "Groovy" + +// Add multiple elements technologies.addAll(["Gradle","Griffon"]) -//Remove an element from the list +/*** Removing elements from the list ***/ + +// As with Java technologies.remove("Griffon") -//Iterate over elements of a list +// Subtraction works also +technologies = technologies - 'Grails' + +// Iterate over elements of a list technologies.each { println "Technology: $it"} technologies.eachWithIndex { it, i -> println "$i: $it"} |