ruby
String#% method allows to specify format to apply to its argument. It can be used to pad numbers with zeros.
Leading zeros
> "%03d" % 2
=> "002"
Trailing zeros
> "%.2f" % 2
=> "2.00"
String#% method allows to specify format to apply to its argument. It can be used to pad numbers with zeros.
> "%03d" % 2
=> "002"
> "%.2f" % 2
=> "2.00"