Skip to content

Instantly share code, notes, and snippets.

@ignacy
Created December 25, 2010 11:08
Show Gist options
  • Save ignacy/754827 to your computer and use it in GitHub Desktop.
Save ignacy/754827 to your computer and use it in GitHub Desktop.
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