我有一些单词,我想得到一个哈希,其中键是单词,值是字数.
有没有更美丽的方式,然后我的:
result = Hash.new(0) words.each { |word| result[word] += 1 } return result
ruby
ruby ×1