5/8 Not adding


puts "Please enter some text:"
text = gets.chomp
words = text.split

frequencies = Hash.new(0)

words.each do
|words| frequencies[words] += 1
puts frequencies

It passes the module, but the console prints:

Please enter some text:
It's not adding anything
{"It's"=>1, "not"=>1}
{"It's"=>1, "not"=>1, "adding"=>1}
{"It's"=>1, "not"=>1, "adding"=>1, "anything"=>1}
["It's", "not", "adding", "anything"]

Why is my code not giving hash entries additive numbers?


Have a read through the explanation


Thank you for the reply, but unfortunately even a direct copy of that code doesn't result in the correct outcome. I still only get a value of 1 for each word.


And what if you use
the text....

text="this is is a long long long text this is"


Ahh, I see. I greatly misunderstood this. I assumed it wanted
The = 1
Numbers = 2
To = 3
Add = 4

Thanks Leonhard.


actually your code already works, I don't know why it wasn't was working for you