From: "Peña, Botp" Date: 2007-03-20T19:24:48+09:00 Subject: Re: C(++) For Loop Equivalents From: Michael W. Ryder [mailto:_mwryder@worldnet.att.net] : # He would need to initialize i before your code as it could be # any value, # not just 0. By the same token the increment could be any number, not # just 1. fwiw, this is a simple example (intended for nubies only). C:\family\ruby>cat -n test.rb 1 #--------------------------- 2 #emulate c++ for (the better) 3 #for(int i=0; i*j/2ruby test.rb using while... 0 1 2 3 4 5 6 7 8 9 Test I. using our own simple for()... note advantage, we don't need to track the counter... 0 1 2 3 4 5 6 7 8 9 Test II. here we initialize to 2 and increment by 2 again, we don't need to track the counter... 2 4 6 8 Test III. again, here we initialize to 200 and decrement by 20 again, we don't need to track the counter... and note, we change keyword unless to if ruby just simply rocks.. 200 180 160 140 120 100 80 60 40 20 C:\family\ruby> Hth. kind regards -botp