Groovy is very powerfull language with tons on inbuilt feature that makes simple things simpler.
Lets look into the code to reverse a String using groovy in its simplest form.
In the above code we directly applied the operation on String literal and used groovy inbuilt support for Range, which are list with sequential values. -1 represent last index value of the String and 0 the start.
Lets use to above code to check if a given String is a palindrome. We call a String Palindrome if it read same forward and backward. Ex nun, malayalam etc.
String name = "malayalam" name[-1..0] == name[0..-1]
true will be returned if string is palindrome else false.