Forum: Ruby Re: Equivalent of Python zfill?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Peña, Botp (Guest)
on 2006-05-29 14:16
(Received via mailing list)
fr Peter:
# in Python this function is ''.zfill(5)
# another possibility would be 5*'0'
# Equivalents in Ruby? I would be mainly interested in a zfill
# equivalent
# since that is faster that join or 5* imho.

same here.

irb(main):043:0> '0'*5
=> "00000"
irb(main):044:0> '0'*3
=> "000"
This topic is locked and can not be replied to.