Skip to content

Instantly share code, notes, and snippets.

@abstractart
Created July 5, 2021 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abstractart/4e5a2539080a5d9a8f67bd419cc98dad to your computer and use it in GitHub Desktop.
Save abstractart/4e5a2539080a5d9a8f67bd419cc98dad to your computer and use it in GitHub Desktop.
A implementation of Fibonacci function using Ruby Fibers
fib = Fiber.new do
last = [0, 1]
while(true)
v = last.sum
last[0] = last[1]
last[1] = v
Fiber.yield v
end
end
10.times do
puts fib.resume
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment