il Sun, 27 Jun 2004 09:37:24 +0900, Gavin Sinclair <gsinclair / soyabean.com.au> ha scritto:: > >* As far as elegance goes, see how you like this: > > longest_length = data.split(/\n/).map { |l| l.length }.max > > The way you've done it will perform better though, I expect. maybe even: longest= data.split(/\n/).sort_by{ |l| l.length }.last to get the line instead of the number of elements (I believe you're keeping the array in memory to handle the lines more then one time)