From: Gunther Diemant Date: 2011-10-20T07:23:49+09:00 Subject: Re: why doesn't this work? In this case, Array.new isn't needed. IMHO a more rubyish way would be: 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