From: Robert Klemme Date: 2011-05-25T00:23:17+09:00 Subject: Re: Using sprintf() to print a Hash On Tue, May 24, 2011 at 1:59 PM, Iñaki Baz Castillo wrote: > 2011/5/24 Iñaki Baz Castillo : >> I've got the following output by using sprintf("%20s %20s", >> "#{key.to_s}:", value.to_s): >> >> ------------------------------------ >>        listen_ip:       1.2.3.4 >>     listen_port:              90 >>         use_tls:            true >>  compression:           false >> ------------------------------------ >> >> but it's not exactly what I need. > > Got it!: > > sprintf("  %-20s %20s", "#{key.to_s}:", value.to_s) That's overly complicated: you employ two text replacement mechanisms. Just do printf(" %-20s: %20s\n", key, value) Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/