Created
October 8, 2010 11:36
-
-
Save aanand/616653 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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 |
This file contains hidden or 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
→ 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