Sorting the hash


I've been working on this all night and cannot seem to grasp what exactly is going on. I understand the histogram portion but the error message is really confusing me since i'm not trying to convert any string into an integer?

its stating that it can't convert string to integer?

puts "Input text please: "
text = gets.chomp
words = text.split
frequencies =
words.each do |words| frequencies[words] =+ 1 
frequencies[words] = frequencies.sort_by do |words, frequencies|


Block parameters are typically a singular of the pluralized object.

words.each { |word| ... }

frequencies.each { |frequency| ... }

This addresses the variable name conflicts, but there are a few other errors in the posted code sample. See if you can make the first few adjustments and then let us have another go at your revised code.


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