From: Nat Pryce Date: 2001-08-06T20:06:05+09:00 Subject: [ruby-talk:19207] Re: Some remarks from a nembie in Ruby From: "Niklas Frykholm" > 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.