Iterating Over the Hash


#1

Having some difficulty understanding my error here. The message I'm getting is just generically telling my code isn't right. Any clarification is appreciated.


puts "Talk to me"

text = gets.chomp

words = text.split(" ")
frequencies = Hash.new(0)
words.each { |word| frequencies[word] +=1 }
frequencies.each do |word, frequency|
puts word + " " frequency.to_s
end


#2
puts word + " " frequency.to_s

You forgot a + operator here.


#3

That is incredibly embarrassing, haha. Thanks for the help!