Skip to content

Instantly share code, notes, and snippets.

@opsb
Created February 18, 2011 11:50
Show Gist options
  • Save opsb/833576 to your computer and use it in GitHub Desktop.
Save opsb/833576 to your computer and use it in GitHub Desktop.
require 'generator'
def before_yield(n)
puts "stopped at #{n}"
n
end
build_plan = Generator.new do |build_plan|
(1..10).each{ |n| build_plan.yield before_yield(n) }
end
puts "running plan"
build_plan.each{ |n| puts "retreived #{n}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment