Advertisement
Guest User

Untitled

a guest
Apr 19th, 2021
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.25 KB | None | 0 0
  1. i = 0
  2. f = Fiber.new do
  3.   loop do
  4.     Fiber.yield i
  5.     i += 1
  6.   end
  7. end
  8.  
  9. e = Enumerator.produce {f.resume}
  10.  
  11. p [0, 0, 0, 0].zip e # [[0, 0], [0, 1], [0, 2], [0, 3]]
  12. p [0, 0, 0, 0].zip e # [[0, 5], [0, 6], [0, 7], [0, 8]]
  13.  
  14. # where does the 4 go?
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement