Forwarding Forwarding - 2 months ago 7
Ruby Question

How to loop through an array using .each starting at an index in Ruby

Ok, so we all know that you can do the following:

array.each{ |value|
puts value
}


What if, however, I want to start at element
n
instead of starting at the beginning; i.e.
n=0
.

Answer

You can also do

array.drop(n).each { |v| puts v }