On 1/16/07, Daniel Martin <martin / snowplow.org> wrote:
> David Madden <moose56 / gmail.com> writes:
>
> >>   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):
>
> Well, okay, we've heard from folks with their fancy 1.9 ruby with
> max_by and that &:sym notation.  However, I'm a little bit surprised
> that this one-liner with inject didn't pop up:
>
> def longest(a)
>   a.inject { |x,y| x.length < y.length ? y : x }
> end

Daniel, this is a much better solution than my sort_by one.  So good work! :)