From: Jim Freeze Date: 2002-12-02T12:51:22+09:00 Subject: Re: For statements On Monday, 2 December 2002 at 11:28:58 +0900, why the lucky stiff wrote: > Daniel Carrera (dcarrera@math.umd.edu) wrote: > > Can I use a for statement to do the equivalent this?: > > 3.step(9,2) {|i| puts i } > > You know that Ranges can be handy with the for..in? > > for i in (3..9).reject { |i| i % 2 == 0 } > puts i > end > > for i in (3..9) > next if i % 2 == 0 > puts i > end Why gives some good suggestions, but why do you want to use a for stateement? For the case given, I think #step is more applicable and probably faster: 3.step(9,2) { |i| puts i } -- Jim Freeze ---------- Nothing astonishes men so much as common sense and plain dealing.