Return to Snippet

Revision: 16036
at July 23, 2009 22:29 by gatement


Initial Code
def number_with_delimiter(number, delimiter=",")
  number.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}")
end

a=1024
p number_with_delimiter(a)

Initial URL

                                

Initial Description
Format an integer with commas to make it more readable

Initial Title
Format an integer with commas

Initial Tags

                                

Initial Language
Ruby