Skip to content

Instantly share code, notes, and snippets.

@yohm
Last active August 29, 2015 13:57
Show Gist options
  • Save yohm/9915522 to your computer and use it in GitHub Desktop.
Save yohm/9915522 to your computer and use it in GitHub Desktop.
count_word
str = "no ruby, no life!"
h = {}
str.scan(/\w+/).each do |word| h[word] = h[word].to_i + 1 end
h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment