DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Finding The Length Of The Longest Word
Source: <a href="http://ruby-doc.org/core/classes/Enumerable.html#M003140">Module: Enumerable</a> [ruby-doc.org]
<snip>
longest = %w{ cat sheep bear }.inject(0) do |memo,word|
memo >= word.length ? memo : word.length
end
longest #=> 5
</snip>





