Is there a Ruby version of for-loop similar to the one in Java/C(++)?
In Java:
for (int i=0; i<1000; i++) {
// do stuff
}
The reason is because I need to do different operations based on the index of the iteration. Looks like Ruby only has a for-each loop?
Am I correct?
Yes you can use each_with_index
the ‘index’ variable gives you the element index during each iteration