Skip to content

Instantly share code, notes, and snippets.

@guenin
Created October 26, 2008 15:12
Show Gist options
  • Save guenin/19898 to your computer and use it in GitHub Desktop.
Save guenin/19898 to your computer and use it in GitHub Desktop.
def make_sandwiches(however_many)
sandwiches = []
however_many.times do
sandwiches << make_sandwich { |sandwich| yield sandwich }
end
sandwiches
end
def make_sandwich
puts "makin a sandwich"
yield
puts "done"
puts
end
make_sandwich do
puts "peanut"
puts "butter"
puts "jelly"
puts "time"
end
make_sandwiches(3) do
puts "bacon"
puts "hamburger"
puts "bacon"
puts "cheese"
puts "bacon"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment