Browsed by
Category: Programming

Ruby Yield and Blocks as a Sandwich

Ruby Yield and Blocks as a Sandwich

Let’s look at yield and blocks by writing a method to make a sandwich. This is great but marketing quickly tells us our one filling sandwiches are way too simple. They want a sandwich function that can have any style of filling in the center. To make it flexible we will define how the filling is printed when we call the function. To do this we use an implicit block. This is great! People start to make all sorts of…

Read More Read More