Skip to content

Instantly share code, notes, and snippets.

@depy
Created Jun 23, 2013
Embed
What would you like to do?
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