How do elegantly rearrange my code so I can get the output {:monosyllabic=>3, :polysyllabic=>4}
instead of the other way around?
def polysyllabic(dictionary)
words = Hash.new(0)
dictionary.each do |word|
if word.scan(/[aeiou]/).size > 1
words[:polysyllabic] += 1
else
words[:monosyllabic] +=1
end
end
polysyllabic(%w(puts locker aero mass ana put pets))
edit: Yes I thought that there are 3 monosyllabics : mass, put, pets. I and some others pronounce "puts" "like "put s" so I want to classify it as polysyllabic. Correct me if I am wrong.