Storing the hash


I don't know what is wrong with this thing but I have been stuck on this for over an hour now and nothing seems to be working even though I can't find anything wrong with my code. please help!


puts "Text please"
text = gets.chomp
words = text.split(" ")
frequencies =
words.each { |word| frequencies[word] += 1 }
frequencies = frequencies.sorty_by { |a, b | b }


Text please
some text
undefined method `sorty_by' for {"some"=>1, "text"=>1}:Hash

console error:

Oops, try again.
It looks like you haven't set the frequencies hash correctly. Check the first exercise if you need help!


sorty_by looks like a typo to me, shouldn't that be sort_by

If you get any error messages in the console you always have to deal with those first, because they mean that your code didn't run to end.


thank you and I swear I don't know how come I could not find it out myself :smile:


Eventually you just learn to look for certain details that keep biting you in the rear.


well said. there's one more thing though:

you can't see something if you are not looking for it even if it's right in front of your eyes - nose


You can still get quite methodical about those things. Eliminating things that it can't be until there isn't much left to look at helps a lot.

Programmers have to spot this kind of stuff all the time

..there will always be situations like that, but we can make them rare