Skip to content

Instantly share code, notes, and snippets.

@aanand
Created October 8, 2010 11:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aanand/616653 to your computer and use it in GitHub Desktop.
Save aanand/616653 to your computer and use it in GitHub Desktop.
def wrapper_method
puts "* SETUP *"
yield
puts "* TEARDOWN *"
end
f = Fiber.new do
wrapper_method do
Fiber.yield
end
end
puts "Resuming f..."
f.resume
puts "f yielded. Now we are between SETUP and TEARDOWN."
puts "Resuming f again..."
f.resume
→ ruby split_block.rb
Resuming f...
* SETUP *
f yielded. Now we are between SETUP and TEARDOWN.
Resuming f again...
* TEARDOWN *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment