I am confused with iterator


I was working on Ruby as a beginner, now making a histogram, but I got confused with the use of iterator. This is the code:

puts "enter ur text mofa"
text= gets.chomp
words= text.split
frequencies= Hash.new(0)

words.each { |word| frequencies [word] += 1 }

My question is: why we used 'word' in the last line instead of 'words'???

thanx in advance, my problem is I cant skip a topic if I don't understand it properly or until it make sense :frowning:


Word is each character in words. Seen by:



it doesn't matter what you use...you could use "i" or "asdf", like this: {|asdf| frequencies[asdf] +=1}, it's just a placeholder. You could use "words" instead of "word" if you'd like, but I think they did that so you wouldn't be confused by the words array variable name.