Skip to content

Instantly share code, notes, and snippets.

@mzdravkov
Last active December 23, 2015 04:49
Show Gist options
  • Save mzdravkov/6582603 to your computer and use it in GitHub Desktop.
Save mzdravkov/6582603 to your computer and use it in GitHub Desktop.
Ruby's fibers (lazy eval example)
all_nums = Fiber.new do
num = 0
while true
Fiber.yield num
num += 1
end
end
all_nums.resume # => 0
all_nums.resume # => 1
all_nums.resume # => 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment