... 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 = 0puts firstMsgwhile true donewMsg = Fiber.yield startputs newMsgstart += 1endend10.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 ...