From: Robert Dober Date: 2007-04-29T23:20:18+09:00 Subject: Re: Array.which_long? ( I coded an extension for Array ) On 4/29/07, David A. Black wrote: > You're doing too much work -- let Ruby do it :-) ... for sure, but > > class Array > def longest > map {|e| e.to_s }.max > end > end I think it is not exactly what OP wanted because %w{x aaaa}.max is "x" so I will try to comply to his needs def longest map{ |e| [e.to_s.size, e.to_s]}.max.first end HTH Robert > > > David > > -- > Upcoming Rails training by Ruby Power and Light: > Four-day Intro to Intermediate > May 8-11, 2007 > Edison, NJ > http://www.rubypal.com/events/05082007 > > -- You see things; and you say Why? But I dream things that never were; and I say Why not? -- George Bernard Shaw