I have a line in which I want 250 characters or less. I did this in a java way, but is there a groovy shortcut for this:
def longString = "This is my really long string.This is my really long string.This is my really long string.This is my really long string.This is my really long string.This is my really long string.This is my really long string.This is my really long string.This is my really long string.This is my really long string.This is my really long string.This is my really long string.This is my really long string.This is my really long string.This is my really long string.This is my really long string.This is my really long string.This is my really long string." def shortString = "This is my really short string." #ideal would be something like: return longString[0..250] #versus how i currently have it #how can i simplify this one... return shortString.size() < 250? shortString: shortString.substring(0,250)
source share