Iterating over the array - undefined method `new' for #<Enumerator: ["gr"]:each>


#1



https://www.codecademy.com/courses/ruby-beginner-en-693PD/0/5?curriculum_id=5059f8619189a5000201fbcb#


I keep getting the message...undefined method `new' for #Enumerator: ["gr"]:each


`

Here is my code:

puts "Type in text here"
text = gets.chomp
words = text.split
frequencies = Hash.new (0)
words.each {|word| frequencies [word] +=1}


#2

please ignore!....i simply was typing in a single word instead of a sentence which prompted the error.


#3

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