Skip to content

Instantly share code, notes, and snippets.

@vanderhoop
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save vanderhoop/3e6723b2d3efd5cebc33 to your computer and use it in GitHub Desktop.

Select an option

Save vanderhoop/3e6723b2d3efd5cebc33 to your computer and use it in GitHub Desktop.

Intro to Yield

  • write a method, yields_to_block, that yields to a block and executes it just once.
    • invoke yields_to_block without passing it a block. What happens?
  • write a method, encore!, that yields to the same block twice.
    • invoke encore! by passing it a block that prints the title of your favorite song to the console.
  • write a method, applaud_all_acts, which takes a block and executes it 5 times. After each execution of the block, the method should print (applause) to the console.
    • invoke this method with some golf-related code. Golf people applaud everything.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment