I started dabbling in groovy yesterday. There's an example on the groovy website that I understand but I would like to know more about why it works the way it does. What's confusing me is who[1..-1]
. Is this like saying who[1..who.length()-1]
? I can't find any documentation on this syntax.
Are there any good groovy tutorials out there besides what is on http://groovy.codehaus.org/?
class Greet {
def name
Greet(who) { name = who[0].toUpperCase() +
who[1..-1] }
def salute() { println "Hello $name!" }
}
g = new Greet('world') // create object
g.salute() // Output "Hello World!"