Over a million developers have joined DZone.

Put Commas Into Long Integers

·
By Lucas Carlson - http://tech.rufy.com/

class Integer
    alias _to_s to_s
    def to_s
        _to_s.reverse.gsub(/(\d{3})/, '\1,').chomp(",").reverse
    end
end
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}