Skip to content

Instantly share code, notes, and snippets.

@kaznum
Created September 29, 2011 15:03
Show Gist options
  • Save kaznum/1250917 to your computer and use it in GitHub Desktop.
Save kaznum/1250917 to your computer and use it in GitHub Desktop.
return the comma separated string of integer.
class Integer
def to_comma_separated()
self.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\1,').reverse
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment