November 29, 2010

Groovy Goodness: String Continuation

Groovy makes writing concise code easy,. We can use the continuation character (\) in a String to split up the definition over multiple lines.

def name ='mrhaki'

def s = "This is not a multiline\
 String, $name, but the continuation\
 character (\\) makes it more readable."
assert 'This is not a multiline String, mrhaki, but the continuation character (\\) makes it more readable.' == s