Created
April 2, 2014 01:21
-
-
Save JunichiIto/9926358 to your computer and use it in GitHub Desktop.
Another implementation of https://gist.github.com/JunichiIto/9914269
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def count_by_word(string) | |
fn = ->(s, h){ h[s] += 1 } | |
string | |
.scan(/\w+/) | |
.each_with_object(Hash.new(0), &fn) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment