From: George Ogata Date: 2004-06-27T11:13:02+09:00 Subject: Re: Writing UNIX 'wc' program Florian Gross writes: > gabriele renzi wrote: > >>> longest_length = data.split(/\n/).map { |l| l.length }.max >> 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) > > For something like this it would be great to have a .max_by built-in. > > Are there any good reasons for not having it? I might write a RCR for > it soon. #max, like #sort, takes a block. That good enough, isn't it?