Skip to content

Instantly share code, notes, and snippets.

@depy
Created June 23, 2013 01:27
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 depy/5843359 to your computer and use it in GitHub Desktop.
Save depy/5843359 to your computer and use it in GitHub Desktop.
class Iter
def initialize(arr)
@f = Fiber.new do
while item = arr.shift
Fiber.yield item
end
end
end
def next
@f.resume
end
end
i = Iter.new [1,2,3,2,1,0]
while item = i.next
puts item
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment