The previous post using the yield statement gives us the following output which shows the ease of using blocks in programs which can be used to pass on parameters to the other parts of the same statement.
The code from the previous post gives the output:
Hi There
Hi There
Hi There
The code between the curly braces is associated to the method three times and within that yield command is called three times in succession, each time calling the code contained within the block giving the three output code in the form of the greeting. We will discuss the concepts behind the ‘yield’ statement in the next posts as we continue to build-up up our skills while aiming to use more of the simplified methods used in ruby to further shorten the code making it easier to implement and use..