Skip to content

Instantly share code, notes, and snippets.

@shunfan
Created December 1, 2013 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shunfan/7728842 to your computer and use it in GitHub Desktop.
Save shunfan/7728842 to your computer and use it in GitHub Desktop.
Word Count
def word_count(content)
result = Hash.new(0)
content.downcase.scan(/\w+/) { |word| result[word] += 1 }
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment