Created
April 5, 2011 22:36
-
-
Save dmitryame/904725 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class String | |
def character_occurance | |
result = {} | |
each_char do |character| | |
result[character] = 0 if result[character] == nil | |
result[character] += 1 | |
end | |
result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment