6. Can't convert string into integer


Says can't convert string into integer as the error

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}


I don't know if this matters, but you're assigning the key/value pairs to frequencies before you actually create the new hash.


after you write

might be resetting frequencies to a new empty hash with a default value of 0?

I'm actually not sure about this but it might be worth a try to reverse those two lines.


That fixed it! Thank you so much!