As you know in ruby you can do
"%03d" % 5
#=> "005"
"%03d" % 55
#=> "055"
"%03d" % 555
#=> "555"
so basically number will have “0” prefix for 3 string places
just wondering is there possibility to do number string suffix in similar nice way ?
(please no if statements)
something 5
#=> 500
something 55
#=> 550
something 555
# => 555
how about ljust method?
and some
to_sandto_imethod calls if you want to do that to integersyou could avoid string conversion with bit more math like
log_10to find number of digits in an integer and theni *= 10**xwherexis how many more 0’s you needlike this: