6 I can't figure out what's wrong


#1

puts "Can I have some text?"
text = gets.chomp
words = text.split
words.each { |word| frequencies[word] += 1}
frequencies = Hash.new(0)
frequencies = frequencies.sort_by {|k, v| v}
frequencies.reverse!


#2

Hi @buckeyefan349,

What error do you get? And please give exercise link?


#3

hey, look, here u're trying to take a value from non existing hash. guess what should you do:)


#4

You're initializing the Hash after trying to add the key/value pairs. That's why it's not working.

puts "Can I have some text?"
text = gets.chomp
words = text.split
words.each { |word| frequencies[word] += 1}
frequencies = Hash.new(0)
frequencies = frequencies.sort_by {|k, v| v}
frequencies.reverse!


#5

increment of word has to replace after hash