From: Gregory Brown Date: 2007-01-16T10:51:18+09:00 Subject: Re: Can anyone try to solve this problems? On 1/15/07, David Madden wrote: > > > 2. Write a function to find the longest string in an array of > > strings. > > > Is this from the Brian Schroder Ruby Course PDF? > > Here is my function (no doubt a better on exists): > > def longest(a) > word = '' > a.each do |i| > if word.length < i.length > word = i > end > end > word > end ['fodfsafdfsdfso','bar','bazzzzzz'].sort_by { |s| s.length }.pop