Skip to content

Instantly share code, notes, and snippets.

@7even
Created April 15, 2012 19:50
Show Gist options
  • Save 7even/2394502 to your computer and use it in GitHub Desktop.
Save 7even/2394502 to your computer and use it in GitHub Desktop.
number formatting
def separate_with_comma(n)
n.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, '\1,')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment