6/8 Syntax error


#1

puts "Enter text please: "
text = gets.chomp
words = text.split
frequencies=Hash.new(0)
words.each = {|word| frequencies[word] += 1 }
frequencies = frequencies.sort_by {|word, count| count}
frequencies.reverse!

This code gives me error:

(ruby):4: syntax error, unexpected '|', expecting '}'
words.each = {|word| frequencies[word] += 1 }
^
(ruby):4: syntax error, unexpected '}', expecting $end

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

Can someone tell me what is wrong here? I've tried everything!!


#2

should be,

words = text.split(' ')
# or
words = text.split(" ")

That's the only obvious error. Try it and let us know.


#3

Just tried it, didn't work. Any other ideas?


#4

Update: this code works in Safari, but not in Chrome. Odd, but I'll take it so long as it means I wasn't screwing up!