[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

change from int 1 on int 01

misiek

2/1/2006 5:49:00 PM

I need to change variable as int = 1 on = 01

wrrrrwrrrrrrrrr
3 Answers

Malte Milatz

2/1/2006 6:42:00 PM

0

misiek wrote:
> I need to change variable as int = 1 on = 01

May you elaborate?

Malte

Matthew Smillie

2/2/2006 12:16:00 AM

0


On Feb 1, 2006, at 21:58, Malte Milatz wrote:

> misiek wrote:
>> I need to change variable as int = 1 on = 01
>
> May you elaborate?

Maybe he wants octal?


Ross Bamford

2/2/2006 1:14:00 AM

0

On Thu, 2006-02-02 at 06:57 +0900, misiek wrote:
> I need to change variable as int = 1 on = 01

Based on the question, this is as likely as not what you're after:

1.to_s.rjust(2,'0')
# => "01"

sprintf('%.2d', 1)
# => "01"

That's strings, though. My math isn't great but I think int 1 *is* int
01 (isn't it?)

1.to_s.rjust(2,'0').to_i
# => 1

--
Ross Bamford - rosco@roscopeco.REMOVE.co.uk