Skip to content

Instantly share code, notes, and snippets.

View zlw5009's full-sized avatar

Zach Williams zlw5009

  • Little Rock, Arkansas
View GitHub Profile
@letladi
letladi / blocks_foundations.md
Created August 13, 2016 05:18 — forked from zlw5009/blocks_foundations.md
An article on Ruby Blocks and Procs

Building a Foundation with &blocks

What is a Block?

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.