0
for(var i = 0; i < 200000; i += 50){
    // Do Stuff
}

The only way I can think to do it is to do the following

arr = [0,50,100,...,200000]
arr.each do |i|
    // Do Stuff
end

If that is in fact the only way. How could you build that array quickly?

2 Answers 2

2
(0..200000).step(50) do |i|
  # Do stuff
end

You can look at the full documentation.

Sign up to request clarification or add additional context in comments.

1 Comment

Ah! Thank you. I just posted another way to do this, but, this is way more efficient.
1
(0...200000).step(50) do |i|
  # Do stuff
end

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.