From: Robert Klemme Date: 2011-05-25T01:13:30+09:00 Subject: Re: Using sprintf() to print a Hash On Tue, May 24, 2011 at 5:29 PM, Xavier Noria wrote: > On Tue, May 24, 2011 at 5:25 PM, Iņaki Baz Castillo wrote: > > 2011/5/24 Robert Klemme : >> >> 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) >> >> Yes, initially I used key.to_s as I have Symbols as keys and thougth >> that a string is required. > > > Note that the colon belongs to the argument though. Otherwise they won't be > next to their keys. Right, I overlooked that. Good catch! I usually prefer to have all colons aligned, that's why I probably didn't notice. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/