typestar

Language basics

29 steps in 10 sets of Ruby.

Ruby was designed to make programmers happy, and you can feel it under your fingers: methods read like sentences, blocks turn loops into one-liners, and the punctuation budget goes to a few well-chosen sigils instead of ceremony. It powered the Rails wave that built Shopify, GitHub and Airbnb, and it remains one of the fastest languages to think in — what you mean and what you type are unusually close together.

This tour covers the language itself: strings and symbols, the core collections, control flow, and the blocks that make Enumerable the best iteration library anywhere. Then methods, classes, modules and the nil-safety idioms of daily Ruby, closing with files, exceptions and JSON. Every seed runs start to finish under Ruby 3.4 before it reaches you.

Start this tour

Variables & strings

  • String interpolationVariables, strings, and the interpolation Ruby reaches for constantly.
  • String methodsThe everyday string toolkit: strip, split, sub and friends.
  • SymbolsWhy Ruby has two kinds of string and when the lightweight one wins.

Collections

  • ArraysBuilding, growing and querying Ruby's workhorse collection.
  • HashesKey-value pairs with defaults, fetch fallbacks and easy iteration.
  • RangesTwo dots or three: Ruby's ranges count, test, step and slice.

Control flow

  • Conditionalsif, elsif, unless and the one-line modifiers that read like prose.
  • case and whenPattern dispatch with ===: ranges, classes and regexps all match.
  • Loopstimes, upto, while and each — and why bare for loops are rare.

Blocks & iterators

  • each and mapThe two iterators that start every Ruby program.
  • select and detectFiltering a collection down to the elements you actually want.
  • reduceFolding a collection into one value, from sums to custom picks.

Enumerable

Methods & blocks

  • Method argumentsDefaults, keyword arguments and splats on ordinary methods.
  • yieldMethods that take a block and decide when to run it.
  • Procs and lambdasBlocks captured as objects you can store, pass and compose.

Classes & modules

Nil & idioms

Files & errors

  • FilesWriting, rewinding and reading a file line by line.
  • Exceptionsraise, rescue, ensure and a custom error class of your own.
  • JSONSerializing to JSON and back with the standard library.

Encore

  • Word frequencyA complete script: scan text, count words, print a ranked table.
  • Markdown TOCA complete script: parse headings and emit a nested contents list.

The other Ruby tours