diff options
| author | Zachary Ferguson <zfergus2@users.noreply.github.com> | 2015-10-06 18:19:20 -0400 | 
|---|---|---|
| committer | Zachary Ferguson <zfergus2@users.noreply.github.com> | 2015-10-06 18:19:20 -0400 | 
| commit | c4f93c0b0ec1fcea11e336b67929b9d6f426765c (patch) | |
| tree | a97e9f7a56330e45122bb81bb5194f2aefe03fdb /groovy.html.markdown | |
| parent | 29cbff176857653422555650c983afef4a28ae1f (diff) | |
| parent | 55c80f255202b03c4c3a66ac1d37f880a3782b68 (diff) | |
Merge remote-tracking branch 'adambard/master'
Conflicts:
	java.html.markdown
Diffstat (limited to 'groovy.html.markdown')
| -rw-r--r-- | groovy.html.markdown | 13 | 
1 files changed, 9 insertions, 4 deletions
| diff --git a/groovy.html.markdown b/groovy.html.markdown index 519f36ce..492c1ba2 100644 --- a/groovy.html.markdown +++ b/groovy.html.markdown @@ -99,7 +99,7 @@ technologies.sort()  // To sort without mutating original, you can do:  sortedTechnologies = technologies.sort( false ) -/*** Manipulating Lists ***/ +/*** Manipulating Lists ***/e  //Replace all elements in the list  Collections.replaceAll(technologies, 'Gradle', 'gradle') @@ -200,6 +200,14 @@ def y = 10  def x = (y > 1) ? "worked" : "failed"  assert x == "worked" +//Groovy supports 'The Elvis Operator' too! +//Instead of using the ternary operator: + +displayName = user.name ? user.name : 'Anonymous' + +//We can write it: +displayName = user.name ?: 'Anonymous' +  //For loop  //Iterate over a range  def x = 0 @@ -422,6 +430,3 @@ Join a [Groovy user group](http://www.groovy-lang.org/usergroups.html)  [1] http://roshandawrani.wordpress.com/2010/10/18/groovy-new-feature-closures-can-now-memorize-their-results/  [2] http://www.solutionsiq.com/resources/agileiq-blog/bid/72880/Programming-with-Groovy-Trampoline-and-Memoize  [3] http://mrhaki.blogspot.mx/2011/05/groovy-goodness-cache-closure-results.html - - - | 
