From: "Simon Kröger" Date: 2007-08-15T05:19:58+09:00 Subject: Re: Does an Array#apply make any sense at all? nikolai.weibull@gmail.com wrote: > On Aug 14, 2:11 pm, Trans wrote: >> On Aug 14, 2:40 am, "nikolai.weib...@gmail.com" > >>> def same_path?(a, b) >>> [a, b].map{ |p| File.expand_path(p).downcase }.apply(:==) >>> end >> Your first solution is much easier to understand. In fact I would do: > >> def same_path?(a, b) >> File.expand_path(a).downcase == File.expand_path(b).downcase >> end > > It's not about the line count but about executing the same set of > functions/methods on both a and b. With the #inject or #apply > solution it's clear that both a and b undergo the same conversion. perhaps you should just give the functions/methods a name: def normalize path File.expand_path(path).downcase end def same_path?(a, b) normalize(a) == normalize(b) end Of course we are drifting far away from the topic of this thread. More on topic: I would think an apply method would apply a function to each member of the array (like map) - just from the sound of word. > nikolai cheers Simon