Thursday, July 16, 2015

Ruby - leading zeros

http://stackoverflow.com/questions/5810468/leading-zeros-in-rails

some_int = 5
some_int.to_s.rjust(2, '0')  # => '05'
some_int.to_s.rjust(5, '0')  # => '00005'

No comments:

Post a Comment

Followers

Blog Archive