Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Another implementation of https://gist.github.com/JunichiIto/9914269
def count_by_word(string)
string
.scan(/\w+/)
.each_with_object(Hash.new(0)){|s, h| h[s] += 1 }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment