From: teresa nuagen Date: 2011-11-05T13:59:29+09:00 Subject: Re: Ruby Challenge Thomas Sawyer wrote in post #1030247: > Why does this sound like a school assignment? > > file = 'sample.txt' > freq = Hash.new{|h,k| h[k] = 0} > File.read(file).scan(/\w+/) do |w| > freq[w] += 1 > end > freq.each do |w,c| > puts "#{c} #{w}" > end > > Untested. There should be an "if" / "else" statement in a looping method, to add the word in list or word count. -- Posted via http://www.ruby-forum.com/.