Created
December 25, 2010 11:08
-
-
Save ignacy/754827 to your computer and use it in GitHub Desktop.
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
require 'fiber' | |
def event_callback(letter) | |
puts "I've encountered #{letter} !!" | |
end | |
f = Fiber.new do | |
('a'..'z').each do |l| | |
Fiber.yield(event_callback(l)) if (l == "c" || l == "h") | |
end | |
end | |
while f.alive? do | |
f.resume | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment