From: Joel VanderWerf Date: 2002-02-18T03:58:26+09:00 Subject: Re: Formatting Sean Russell wrote: > > > > David Corbin wrote: > > > In C, people use printf to format data nicely for display. In Java, > > it's NumbeFormat, DateFormat, etc. > > > > What is the best way to do this in Ruby? > > Ruby also has printf. > > If you're doing a single data, you can format it with %: > > out = "%05d"%20 # -> 00020 Works with multiple data items, too: irb(main):001:0> "%s, %s!" % ["Hello", "world"] "Hello, world!"