Nat Pryce wrote:
> 
> From: "Niklas Frykholm" <r2d2 / acc.umu.se>
> > On Mon, Aug 06, 2001 at 05:24:47PM +0900, Renaud HEBERT wrote:
> > > 9) Another construct that could be improved IMHO: 0.step(12,3) ...
> >
> > Agreed, it's one of those things that you always have to look at a bit to
> > realize how it steps.
> 
> I'd prefer it as a method on the Range class.  E.g. this looks more natural
> to me:
> 
> (1..12).step(3) { |i| puts i.to_s }
> 
> And of course, you can write that in Ruby because Ruby classes are open.
> For example:
> 
> class Range
>     def step( step_size )
>         i = 0
>         while i < length
>             yield start + i
>             i += step_size
>         end
>     end
> end
> 
> Note ... this is just a sketch.  I haven't tested it.  That's left as an
> exercise to the reader :-)
> 
> Cheers,
>         Nat.

I like it: it is much more natural and nearly right:
replace "yield start + i" by "yield first + i" and it works :-)

It "reads" really right: how about integrating the method Range.step in
the language?

-- 
Renaud Hebert
phone: (33) 01 30 77 59 92
mailto:renaud.hebert / alcatel.fr