Blocks are code contained within the braces that if used with the last post’s example would be associated with the call to the function threeTimes. Within the defined method a call for yield is called three times in a row wherein each time a call to the block is sent the greeting is displayed which in this case is three times. Blocks are interesting for they can be passed on to and received from, values that have been processed by another function. The next example would have the block display the values of the Fibonacci Series of numbers to a set number of times that we will set. The Next Post would show an example of this using a block to return the values.
Constructing Blocks
This entry was posted in Development, Programming Basics and tagged Blocks, Functions. Bookmark the permalink. Comments are closed, but you can leave a trackback: Trackback URL.
