V
Vladimir Agafonkin
Hi.
How can I pad a number with "0"-s to a speciefied length when it goes
to the output? It's a very simple newbie question, yet I haven't been
able to find an answer in Programming Ruby book and core library docs.
Say, we have a following code:
for i in 1..10 do
puts "num #{i}"
end
What I need to change in this little script to format the output so
that it looks like this?
num 01
num 02
....
num 10
Thanks in advance.
How can I pad a number with "0"-s to a speciefied length when it goes
to the output? It's a very simple newbie question, yet I haven't been
able to find an answer in Programming Ruby book and core library docs.
Say, we have a following code:
for i in 1..10 do
puts "num #{i}"
end
What I need to change in this little script to format the output so
that it looks like this?
num 01
num 02
....
num 10
Thanks in advance.