In this code:
fiber = Fiber.new do |first, second|
num = Fiber.yield first + second + 2
end
puts fiber.resume 5, 4
puts fiber.resume 3
The output is 11
and 3
each on a separate line.
I understand why the output is 11
for the first fiber.resume
(its parameters are passed as block arguments to Fiber.new
) but I don't understand why the second fiber.resume
returns 3
. What's going on?