summaryrefslogtreecommitdiffhomepage
path: root/groovy.html.markdown
diff options
context:
space:
mode:
authorTim Yates <tyates@picr.man.ac.uk>2013-09-02 12:59:18 +0100
committerTim Yates <tyates@picr.man.ac.uk>2013-09-02 12:59:18 +0100
commit6f444bece417a18127782d909a518c91962823c9 (patch)
tree0d13aefd6b2739aa1aa5729165ea633794b3e959 /groovy.html.markdown
parent68f26804c54280ad86ce639ae428fdf3b670de8b (diff)
Mention mutating with List.sort
Diffstat (limited to 'groovy.html.markdown')
-rw-r--r--groovy.html.markdown6
1 files changed, 5 insertions, 1 deletions
diff --git a/groovy.html.markdown b/groovy.html.markdown
index 63cef76b..135efc0f 100644
--- a/groovy.html.markdown
+++ b/groovy.html.markdown
@@ -51,6 +51,7 @@ println x
/*
Collections and maps
*/
+
//Creating an empty list
def technologies = []
@@ -81,9 +82,12 @@ technologies.eachWithIndex { it, i -> println "$i: $it"}
technologies.contains('Groovy')
technologies.containsAll(['Groovy','Grails'])
-//Sort a list
+// Sort a list (mutates original list)
technologies.sort()
+// To sort without mutating original, you can do:
+sortedTechnologies = technologies.sort( false )
+
//Replace all elements in the list
Collections.replaceAll(technologies, 'Gradle', 'gradle')