Ruby - Find The Longest Word In A Sentence
Another fine use of .inject
straight from the ruby-doc manual
words = %w{the longest word this sentence is undoubtedly hocem }
theWinner = words.inject do |longestWord, currentWord|
longestWord.length > currentWord.length ? longestWord : currentWord
end
p theWinner