-
-
Save cscheib/b9f5a523a0acf375760e to your computer and use it in GitHub Desktop.
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(array) | |
result = {} | |
array.uniq.each { |e| result[e] = array.count(e) } | |
end | |
p count(['a', 'a', 'b', 'b', 'b']) |
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
arctistor:rubylearning chris$ ruby element_count.rb | |
["a", "b"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment