Skip to content

Ruby Programming Textbook

A free, self-paced textbook in 7 chapters. Read a chapter, then drill it with the 50 companion flashcards using spaced repetition.

7 chapters · 50 cards · Updated

Chapters

  1. 1Core Data Structures

    Ruby provides several built-in data structures for organizing information in programs. A Symbol is a lightweight, immutable identifier written with a leading colon, such as :status...

  2. 2Blocks, Procs, and Lambdas

    Ruby treats blocks of code as first-class values that can be passed to methods. A block is an anonymous chunk of code written either with curly braces or with the do and end keywor...

  3. 3Classes, Inheritance, and Modules

    Ruby is fundamentally object-oriented, and classes are defined with the class keyword followed by the class name and a body of method definitions. When an object is created with Cl...

  4. 4Iterators and Functional Collections

    Iteration is at the heart of idiomatic Ruby, and most collection methods are powered by the Enumerable module. The each method is the workhorse of iteration: it walks through a col...

  5. 5Exception Handling and File I/O

    Ruby programs use a structured exception handling mechanism built around the begin, rescue, and ensure keywords. Risky code is wrapped in a begin block, and any raised exception th...

  6. 6Strings, Patterns, and Operators

    Strings in Ruby can be constructed with single or double quotes, but only double-quoted strings support interpolation, where the result of any Ruby expression can be embedded with...

  7. 7Metaprogramming and the Ruby Ecosystem

    One of Ruby's most distinctive features is metaprogramming, the ability to write code that writes or modifies code at runtime. The define_method method dynamically defines an insta...

← Back to the Ruby Programming deck