Created
April 18, 2018 06:54
-
-
Save a2ikm/ec242106c98814f09b8517bd3f0d079e to your computer and use it in GitHub Desktop.
Fiberの1回目のresumeでとりあえずブロック処理に突入させる
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fib = Fiber.new do | |
Fiber.yield # y1 | |
a, b = 1, 1 | |
while true | |
Fiber.yield(a) # y2 | |
a, b = b, a + b | |
end | |
end | |
fib.resume # y1まで進める | |
10.times do |n| | |
p [n, fib.resume] # y2を処理する | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment