Tips For Golfing In Groovy As I have seen many questions asking tips for golfing in their interested language, I decided to ask for my favorite language: Groovy. People can give some tips and tricks that will be used in golfing with Groovy.
I'm new to this whole golfing thing, this is what I got so far:

Use Closures not functions:


def a(b){print b}


is longer than


a={print it}


You can use a negative index in arrays and lists as an alias for size()-


c = "abc"
d = ["a", "b", "c"]

assert c[c.size()-1] == c[-1]
assert c[c.size()-2] == c[-2]
assert d[d.size()-1] == d[-1]
assert d.last() == d[-1]


The spread operator is a shortcut for collect:

assert d*.size() == d.collect{it.size()}

For sorting use the spaceship operator:

e = [54,5,12]
assert e.sort{a,b-&gt;a&lt;=&gt;b}==e.sort{a,b-&gt;a&lt;b?-1:+1}
assert e.sort{a,b-&gt;a&lt;=&gt;b}==e.sort{a,b-&gt;if (a&gt;b) {return(-1)} else {return(+1)}}


Edit Conversions: 

assert "123" as int == "123".toInteger()