Skip to content

Instantly share code, notes, and snippets.

@casper
Created June 16, 2012 00:55
Testing Ruby Enumerator + yield lookahead
$i = 0
o = Object.new
def o.each
yield $i += 1
yield $i += 1
yield $i += 1
end
e = o.to_enum
loop do
puts "#{$i}"
puts "NEXT: " + e.next.to_s
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment