From: "Michael C. Libby" Date: 2002-12-02T10:13:54+09:00 Subject: Re: For statements -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sunday 01 December 2002 18:28, Daniel Carrera wrote: > for (i = 0; i < num; i += 3) ... > > Does the for statement have any form other than 'for i in array ...'? > > Can I use a for statement to do the equivalent this?: > 3.step(9,2) {|i| puts i } Question is, why do you want to? You've found a clear way to accomplish it using step. Perhaps you want to modify the loop boundary while the loop is executing... So, if you really want to emulate the C-style for loop, simply use a while loop. The C-style for loop is really just a while loop in disguise. i = 3 num = 9 while i <= num do puts i i += 2 end -michael -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE96rNt4ClW9KMwqnMRAomXAKCFmMTjOtE3fmg0RAUrAUuGSn9PfgCeKbkT ddPtrxVs4eZXMBVHG4RRVkA= =7Ngp -----END PGP SIGNATURE-----