Ruby: Is it possible to have a for loop that increases more than one at a time?

Posted by zxcvbnm on Stack Overflow See other posts from Stack Overflow or by zxcvbnm
Published on 2010-04-13T21:17:46Z Indexed on 2010/04/13 21:23 UTC
Read the original article Hit count: 204

Filed under:
|
|

For example:

for(int i = 0; i < 100; i += 2)

I could use a while loop or check if i % 2 == 0, but I was wondering if there wasn't a way to do it with the for loop. I could also use for(int i = 0; i < 50; i++) and multiply i by 2, but that doesn't seem right either. I'm just wondering if there is a simple, straightforward way to do it.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about loop