Use the `next` statement.
http://www.tutorialspoint.com/ruby/ruby_loops.htm
--
Dheeraj Kumar
On Thursday 23 May 2013 at 2:54 PM, Ajit Teli wrote:
> Can anyone help me on how to skip index in ARRAY.each_with_index loop?
>
> Please look at below case:
>
> In a ARRAY.each_with_index loop, I would like increase the index by 10
> whenever a condition is met.
>
> arr is array of numbers from 0 to 50
> arr.each_with_index do |x,i|
> if i % 10 == 0
> puts "#{x} at #{i}"
> i = i+10 //index increased by 10
> end
> end
>
> The output should be:
> 10 at 10
> 30 at 30
> 50 at 50
>
> Thanks
> Ajit
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> (mailto:[email protected]).
> To post to this group, send email to [email protected]
> (mailto:[email protected]).
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/d060dba071d03754b6d3f816898091eb%40ruby-forum.com?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/C9D341988142443CAD90D906536A9EB6%40gmail.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.