Block

Noun · Development

Definitions

  1. In Ruby, an anonymous chunk of code enclosed in do...end or curly braces that can be passed to a method and executed via yield — acting as a lightweight closure. More broadly, a lexically scoped group of statements in any language.

    In plain English: A chunk of code you can pass around and run later, commonly used in Ruby to do something with each item in a list.

    Example: "Pass a block to .map and Ruby will yield each element to your code in turn."

Related Terms