Skip to content

Instantly share code, notes, and snippets.

@dzwdz
Created April 19, 2021 14:15
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 dzwdz/4966c7c5ada7e91efc8a51875bf61fe8 to your computer and use it in GitHub Desktop.
Save dzwdz/4966c7c5ada7e91efc8a51875bf61fe8 to your computer and use it in GitHub Desktop.
i = 0
f = Fiber.new do
loop do
Fiber.yield i
i += 1
end
end
e = Enumerator.produce {f.resume}
p [0, 0, 0, 0].zip e # [[0, 0], [0, 1], [0, 2], [0, 3]]
p [0, 0, 0, 0].zip e # [[0, 5], [0, 6], [0, 7], [0, 8]]
# where does the 4 go?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment