refer an enumerator value with specified index
You could use take
to peel off the first three elements and then last
to grab the third element from the array that take
gives you:
third = enum.take(3).last
If you don't want to generate any arrays at all then perhaps:
# If enum isn't an Enumerator then 'enum = enum.to_enum' or 'enum = enum.each'
# to make it one.
(3 - 1).times { enum.next }
third = enum.next
Alternative to mu's answer using enumerable-lazy or Ruby 2.1. As lazy as using next
but much more declarative:
enum.lazy.drop(2).first