Created
January 23, 2020 01:17
-
-
Save beatmadsen/10715761ebd13e740313aa3b9d36c782 to your computer and use it in GitHub Desktop.
An example of how fibers work
This file contains 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
f = Fiber.new do | |
a = 42 | |
loop do | |
Fiber.yield(a) | |
a += 1 | |
end | |
end | |
f.resume # => 42 | |
f.resume # => 43 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment