I have an integer number like 1111, How can I get a string like below
by the string#% ?
"11110000"
I know "%-8d" % 1111 can get "1111 ".
Thank you.
I have an integer number like 1111, How can I get a string like below
by the string#% ?
"11110000"
I know "%-8d" % 1111 can get "1111 ".
Thank you.
Is String#% a requirement or just your first idea?
num = 1111
p num.to_s.ljust(8,"0")
#> "11110000"
Harry
On Wed, Dec 1, 2010 at 5:29 PM, jun yu <mail2fish@gmail.com> wrote:
I have an integer number like 1111, How can I get a string like below
by the string#% ?"11110000"
I know "%-8d" % 1111 can get "1111 ".
Thank you.