Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. words = ["foo", "var", "spam", "egg", "foo", "foo", "egg"]
  2. frequency = {}
  3. words.each{|word| frequency[word] += 1}
  4.  
  5. puts(frequency) #{"foo" => 3, "var" => 1, "spam" => 1, "egg" => 2}
  6.  
  7. prueba.rb:3:in `block in <main>': undefined method `+' for nil:NilClass (NoMethodError)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement