Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@casper
Created June 16, 2012 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save casper/2939417 to your computer and use it in GitHub Desktop.
Save casper/2939417 to your computer and use it in GitHub Desktop.
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