From: Nicholas Van Weerdenburg Date: 2005-01-13T01:24:48+09:00 Subject: Re: Comparing two files for equality end is the end of an expression that returns an array. # this is quivalent. a=files.map do |file| ... end a.uniq # Since everything in ruby is an expression, you can do: files.map do |file| ... end.uniq # making the expression explicit... (files.map do |file| .... end).uniq Regards, Nick On Thu, 13 Jan 2005 01:15:25 +0900, Andreas Semt wrote: > Florian Gross wrote: > > > > def files_equal?(*files) > > files.map do |file| > > File.size file > > end.uniq.size <= 1 and > > files.map do |file| > > File.read file > > end.uniq.size <= 1 > > end > > > > Could anybody please explain the "end.uniq.size" line? > Thanks! > > Greetings, > Andreas > > > This ought to be slightly faster in the average case. > > > > Other optimizations would be reading the files line-wise in parallel and > > bailing out as soon as one of the lines differs. > > > > -- Nicholas Van Weerdenburg