From: botp Date: 2011-10-20T12:48:05+09:00 Subject: Re: why doesn't this work? On Thu, Oct 20, 2011 at 6:23 AM, Gunther Diemant wrote: > def find_frequency(sentence, word) >  sentence.split(/ /).select { |w| w.downcase == word.downcase }.length > end > or maybe even better: > def find_frequency(sentence, word) >  sentence.split(/ /).map { |w| w.downcase }.count(word.downcase) > end count does accept a block, so def find_frequency(sentence, word) word=word.downcase sentence.split.count{ |w| w.downcase == word} end