[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: Number formatting
From:       "Luis Parravicini" <lparravi () gmail ! com>
Date:       2007-05-31 16:13:44
Message-ID: ff2660880705310913l6aa9c6bay839f673507c4213 () mail ! gmail ! com
[Download RAW message or body]

On 5/31/07, Cory <coryw@americanmonkey.com> wrote:
> folks - can't quite figure this one out...
>
> foo = 5
> bar = 10
>
> basically - when i go to print out the numbers - i want to format 'foo'
> with a leding zero so that it reads '05' and is aesthetically pleasing
> when compared to a double-digit number - such as bar: '10'.

  Try using Kernel#printf.

irb(main):001:0> printf("%02d", 5)
05=> nil


-- 
Luis Parravicini
http://ktulu.com.ar/blog/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic