From: Robert Klemme Date: 2009-12-08T22:48:34+09:00 Subject: Re: indent strings(make them lined up) 2009/12/8 Steve Wilhelm : > Thomas Sawyer wrote: >> On Dec 7, 11:26�pm, Jon Kim wrote: >>> www.google.com� � => 123.123.123.12www.ibm.com� � � �=> 123.112.123.12www.iowahawkeyes� => 123.123.112.12 >>> >>> original code was >>> >>> puts (dns + " => " + ip) >>> >>> I tried next code >>> >>> puts (dns + " �"*(20 - dns.length) + " = > " + ip) >>> >>> but it did not work well. please teach me how to do it. >> >> "%-30s %s" % [dns, ip] > > Thomas's suggestion of String Format (%) is correct, just revising > example to reflect the original code above. > > puts "%-20s => %s" % [dns, ip] I'd prefer printf in that case printf "%-20s => %s\n", dns, ip Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/