Blocks... What are they anyway? You've probably used them without even realizing it and most certainly have seen them, but do you know what they are?
If we wanted to take a simplistic approach at defining a block we could say:
A block is a chunk of code contained within the
do..end
or { curly braces } syntax that is to be executed at some point in time.
With that being said, if you've ever used the Enumerable#map
or Enumerable#each
method, you've probably used a block. Lets take a look at two different types of blocks before we go into more detail about what a block really is.