From: Austin Ziegler Date: 2007-03-20T09:36:26+09:00 Subject: Re: C(++) For Loop Equivalents On 3/19/07, studlee2 wrote: > What is the most efficient way in Ruby to create a conditional loop in > Ruby that looks like this in C(++): > > for(int i=0; i*j/2 { > //cool method stuff > } > > > I was looking at the .upto() method but it doesn't like the comparison > operator :-/ Wouldn't it be better to figure out what you're trying to do than look for a general construct? >> max = 200 => 200 >> j = 35 => 35 >> i = 0 => 0 >> 0.upto(max) { |i| break if (i * j / 2) >= max } => nil >> i => 12 That will do the job. -austin -- Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/ * austin@halostatue.ca * http://www.halostatue.ca/feed/ * austin@zieglers.ca