Groovy String Access

def 'Accessing Strings in Groovy is easy.'
 
assert 'A' == s[0]
assert 'A' == s.getAt(0)
assert 'Groovy' == s[21..26]  // We can use ranges.
assert 'easy.' == s[s.indexOf('ea')..-1]
 
// We can also use each method on a String.
s[21..26].each println "$it-" // Output: G-r-o-o-v-y-

Comments

Popular posts from this blog

தட்டு வண்டியில் காளிக்கோயில் - சிறுகதை

பிரேமாவின் பெண் குழந்தை

தீபம் பிளக்ஸ்