Thanks for the replies. I hadn't looked at Enumerator before, I think
that will do the trick. I kind of agree it's not the prettiest looking
code, but I'll write my own #map, #to_a, etc and won't have to look at
it again.
> I heard rumor that a future Ruby will ultimately pass thru each
> parameters, but in the mean time you can have a go with Facets
> enumerablepass.rb (http://facets.rubyforge.org).
I'll look into that too... I see quite a lot of people using facets in
the code and have been meaning to check it out. It seems like passing
parameters along would've been easy and very useful, I'm sort of
surprised it's not already that way.
Cheers,
Erwin
On 5/21/07, James Edward Gray II <> wrote:
> On May 21, 2007, at 10:55 AM, Robert Klemme wrote:
>
> > On 21.05.2007 17:51, Trans wrote:
> >> On May 21, 10:35 am, Robert Klemme <shortcut...@googlemail.com>
> >> wrote:
> >>>> An alternative is to use a functor (a function delegator) for your
> >>>> parameters, eg.
> >>>> f = Foo.new
> >>>> f.range(1,5).each{|x| p x}
> >>> ... which is basically the same as using to_enum - only less
> >>> portable;
> >>> to_enum works with *all* methods. 
> >> That true. But at least it reads much better.
> >
> > Even that is subjective: I personally prefer to read f.to_enum
> > (:range, 1, 5) because then I know this is going to be capable of
> > all the Enumerable methods. YMMD though. 
>
> I agree. It's also worth noting that to_enum() is aliased to enum_for
> () which I think often reads a little better.
>
> James Edward Gray II
>
>