5. Iterating over the Array



I do not understand what is wrong in mi=y code !
"It looks like you haven't added any key-value pairs to the frequencies hash."

puts "please write your text"
text = gets.chomp
words = text.split(" ")

frequencies = Hash.new(0)
words.each { |word| frequencies[word] += 1 }


what do you enter when prompted by chomp? the only way i can get your error with your code is by not typing any text and pressing enter immediately. Enter some text when prompted


Thanks stetim94, it worked great!


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