# Each\_with\_index. Can you start at a desired index position?

**URL:** <https://www.ruby-forum.com/t/each-with-index-can-you-start-at-a-desired-index-position/94744>\
**Category:** Rails\
**Created:** [May 12, 2006, 5:19pm UTC](https://www.ruby-forum.com/t/each-with-index-can-you-start-at-a-desired-index-position/94744 "2006-05-12T17:19:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![crenner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/278dde/32.png) [@crenner](https://www.ruby-forum.com/u/crenner)\
**Post date:** [May 12, 2006, 5:19pm UTC](https://www.ruby-forum.com/t/each-with-index-can-you-start-at-a-desired-index-position/94744/1 "2006-05-12T17:19:00Z")

</div>

When using array.each\_with\_index how do you start at a desired index  
position?

I can do it like this, but its not very clean and doesnt seem efficient  
:

desired\_index\_start = 20  
array.each\_with\_index do |value,index|  
next if index\<desired\_index\_start  
end

Thanks  
Chris

---

<div class="post-metadata">

**Author:** ![crenner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/278dde/32.png) [@crenner](https://www.ruby-forum.com/u/crenner)\
**Post date:** [May 12, 2006, 7:41pm UTC](https://www.ruby-forum.com/t/each-with-index-can-you-start-at-a-desired-index-position/94744/2 "2006-05-12T19:41:45Z")

</div>

Here’s one way.

array[20…-1].each\_with\_index do |value,index|  
…  
end

Brian B.
