From: Leslie Viljoen Date: 2006-05-22T20:53:13+09:00 Subject: Re: rubynuby - confused by method name "inject" On 5/22/06, Farrel Lifson wrote: > > ..then again, using inject to find longest seems a bit silly... > > > > longest_sample = data[0] > > data.each do |sample| > > longest_sample = sample if sample.length > longest_sample.length > > end > > puts "Longest sample: #{longest_sample.inspect}, length #{longest_length}" > > longest_sample = data.max{|a,b| a.length <=> b.length} Yes precisely! That's what I like about Ruby, everyone's a smartypants! (one day I will be too!)