TRANS wrote:
> On 5/20/07, Joel VanderWerf <vjoel / path.berkeley.edu> wrote:
...
>> Is it better in some cases to control this behavior by argument passing
>> rather than by calling an extra method?
> 
> In can avoid an if condition:
> 
>  path.ascend(condition) {|v| p v}
> 
> vs.
> 
>  condition ?  path.ascend {|v| p v} : path.parent.ascend {|v| p v}

which can be refactored:

(condition ? path : path.parent).ascend {|v| p v}

> Though a variable condition is probably pretty rare, so maybe yours is
> the better suggestion.
> 
> However I've made the same extensions to String (ie. String#ascend)
> for use with File.join. In this case, we can't use #parent, so the
> parameter becomes much more important. Unless there's going to be some
> big push for the use of Pathname over File.join (which I would happily
> support btw) then I think it would be nice to have corresponding
> parameters for Pathname's methods.

I'd prefer using Pathname too. Why should a String method (#ascend) know 
anything about file paths?

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407