... continued

This lesson continues the discussion on working with Fibers.

We'll cover the following...

Passing and Returning from Fibers

We can pass and return values from fibers. Consider the snippet below:

Press + to interact
fib = Fiber.new do |firstMsg|
start = 0
puts firstMsg
while true do
newMsg = Fiber.yield start
puts newMsg
start += 1
end
end
10.times do |i|
puts fib.resume("hello #{i}")
sleep(1)
end

The interesting line in the above snippet is:

    newMsg = Fiber.yield start

The above statement can be conceptually broken down as the ordered ...