atom feed8 messages in org.codehaus.groovy.user[groovy-user] really basic question.....
FromSent OnAttachments
RickJun 24, 2009 10:39 pm 
Guillaume LaforgeJun 24, 2009 10:44 pm 
simonzJun 24, 2009 10:58 pm 
Bob BrownJun 24, 2009 11:00 pm 
Bob BrownJun 24, 2009 11:11 pm 
RickJun 25, 2009 6:34 am 
Guillaume LaforgeJun 25, 2009 6:39 am 
RickJun 25, 2009 6:43 am 
Subject:[groovy-user] really basic question... I want to prepend/pad a string with spaces
From:Rick (ric@gmail.com)
Date:Jun 24, 2009 10:39:13 pm
List:org.codehaus.groovy.user

If I'm building a concatenated String...

def s = "foo Bar" s += " FOO"

Sometimes I want to prepend spaces before my next concatenation. What's the best way? I thought padLeft might help, but I couldn't get it work correctly. I know this is a way too verbose:

def pad = "" (1..padAmount).each{ pad += " "}

s += "$pad FOO_BAR"

if padAmount was 5 you end up with "fooBar FOO FOO_BAR"

What's the cleanest way to add variable size String of spaces?