From: Austin Ziegler Date: 2004-01-22T13:11:48+09:00 Subject: Re: New to Python: my impression v. Perl/Ruby On Thu, 22 Jan 2004 05:59:58 +0900, GGarramuno wrote: > for i in (0..i); something; end > > > to me has a bunch of advantages over times, step and the such. With the > above construct you know that: a) i has to be a number b) i has to be > positive for the loop to run c) there IS a loop after all, as 'for' > indicates a loop in pretty much every computer language. d) it is more > efficient as no blocks are created. e) you can change the starting point > (ie. not start at 0). Right. But I could do: ('a'..'z').each { |i| ... } With Ruby, things *don't* need to be numbers to work intelligibly. Also, your point d is, um, well, not true. In Ruby, the for construct is syntax sugar for another loop. Aside from this, why stick with x.times? x.upto(y) { |i| ... } x could be -9 or 32768; as long as y is larger than x, it will work. This pretty much eliminates all of the objections you had. Once you get used to iteration instead of explicit loops, then it's not a big deal to do x.times, x.upto(y) or y.downto(x). -austin -- austin ziegler * austin@halostatue.ca * Toronto, ON, Canada software designer * pragmatic programmer * 2004.01.21 * 23.07.29