Iterating over hash error


I've been looking through problems other people have been having with this particular lesson, and nothing has really helped. I've double-checked my code, and I can't find anything wrong with it, but I keep getting the same error message: undefined local variable or method `word' for #
What am I doing wrong?

puts "Enter text"
text = gets.chomp
words = text.split
frequencies =[0]
    word.each do |word|
    frequecies[word] += 1 
    puts frequencies[word]


I haven't looked too deep into the code, but what I've noticed is, that the quoted code should have round brackets instead of rectangular one.


I've tried that and got a similar message


use frequencies as a variable.

Then iterate through words.


I can't post my solution here. But my solution doesn't have this:


Ok I'll try changing it thx :slight_smile:


So far, nothing I've tried has worked (even switching browsers, as I've seen has been a fix for some users with the same code). I fixed the piece of code that lett mentioned, but I'm still stuck.


Iterate over the container object (array)



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.