Skip to content

Instantly share code, notes, and snippets.

@edward
Forked from guenin/gist:19898
Created October 26, 2008 15:12
Show Gist options
  • Select an option

  • Save edward/19899 to your computer and use it in GitHub Desktop.

Select an option

Save edward/19899 to your computer and use it in GitHub Desktop.

Revisions

  1. @guenin guenin created this gist Oct 26, 2008.
    29 changes: 29 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    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